Exception: GraphQL::ExecutionError

Inherits:
Error
  • Object
show all
Defined in:
lib/graphql/execution_error.rb

Overview

If a field’s resolve function returns a ExecutionError, the error will be inserted into the response’s ‘“errors”` key and the field will resolve to `nil`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ast_nodeGraphQL::Language::Nodes::Field

Returns the field where the error occured.

Returns:



7
8
9
# File 'lib/graphql/execution_error.rb', line 7

def ast_node
  @ast_node
end

Instance Method Details

#to_hHash

Returns An entry for the response’s “errors” key.

Returns:

  • (Hash)

    An entry for the response’s “errors” key



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/graphql/execution_error.rb', line 10

def to_h
  hash = {
    "message" => message,
  }
  if ast_node
    hash["locations"] = [
      {
        "line" => ast_node.line,
        "column" => ast_node.col,
      }
    ]
  end
  hash
end