Exception: GraphQL::ExecutionError
- 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
.
Direct Known Subclasses
AnalysisError, InvalidNameError, Query::OperationNameMissingError, Query::VariableValidationError, Schema::TimeoutMiddleware::TimeoutError
Instance Attribute Summary collapse
-
#ast_node ⇒ GraphQL::Language::Nodes::Field
The field where the error occured.
-
#path ⇒ String
response which corresponds to this error.
Instance Method Summary collapse
-
#initialize(message, ast_node: nil) ⇒ ExecutionError
constructor
A new instance of ExecutionError.
-
#to_h ⇒ Hash
An entry for the response's "errors" key.
Constructor Details
#initialize(message, ast_node: nil) ⇒ ExecutionError
Returns a new instance of ExecutionError.
14 15 16 17 |
# File 'lib/graphql/execution_error.rb', line 14 def initialize(, ast_node: nil) @ast_node = ast_node super() end |
Instance Attribute Details
#ast_node ⇒ GraphQL::Language::Nodes::Field
Returns the field where the error occured.
8 9 10 |
# File 'lib/graphql/execution_error.rb', line 8 def ast_node @ast_node end |
#path ⇒ String
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_h ⇒ Hash
Returns An entry for the response's "errors" key.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/graphql/execution_error.rb', line 20 def to_h hash = { "message" => , } if ast_node hash["locations"] = [ { "line" => ast_node.line, "column" => ast_node.col, } ] end if path hash["path"] = path end hash end |