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

Constructor Details

#initialize(message, ast_node: nil, options: nil) ⇒ ExecutionError



17
18
19
20
21
# File 'lib/graphql/execution_error.rb', line 17

def initialize(message, ast_node: nil, options: nil)
  @ast_node = ast_node
  @options = options
  super(message)
end

Instance Attribute Details

#ast_nodeGraphQL::Language::Nodes::Field



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

def ast_node
  @ast_node
end

#optionsHash



15
16
17
# File 'lib/graphql/execution_error.rb', line 15

def options
  @options
end

#pathString

response which corresponds to this error.



12
13
14
# File 'lib/graphql/execution_error.rb', line 12

def path
  @path
end

Instance Method Details

#to_hHash



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/graphql/execution_error.rb', line 24

def to_h
  hash = {
    "message" => message,
  }
  if ast_node
    hash["locations"] = [
      {
        "line" => ast_node.line,
        "column" => ast_node.col,
      }
    ]
  end
  if path
    hash["path"] = path
  end
  if options
    hash.merge!(options)
  end
  hash
end