Class: GraphQL::Query::Context::ExecutionErrors

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/query/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(ctx) ⇒ ExecutionErrors

Returns a new instance of ExecutionErrors.



86
87
88
# File 'lib/graphql/query/context.rb', line 86

def initialize(ctx)
  @context = ctx
end

Instance Method Details

#add(err_or_msg) ⇒ Object Also known as: >>, push



90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/graphql/query/context.rb', line 90

def add(err_or_msg)
  err = case err_or_msg
  when String
    GraphQL::ExecutionError.new(err_or_msg)
  when GraphQL::ExecutionError
    err_or_msg
  else
    raise ArgumentError, "expected String or GraphQL::ExecutionError, not #{err_or_msg.class} (#{err_or_msg.inspect})"
  end
  # This will assign ast_node and path
  @context.add_error(err)
end