Class: GraphQL::Query::Context::FieldResolutionContext
- Inherits:
-
Object
- Object
- GraphQL::Query::Context::FieldResolutionContext
- Extended by:
- Forwardable
- Defined in:
- lib/graphql/query/context.rb
Instance Attribute Summary collapse
-
#irep_node ⇒ Object
readonly
Returns the value of attribute irep_node.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#add_error(error) ⇒ void
Add error to current field resolution.
-
#ast_node ⇒ GraphQL::Language::Nodes::Field
The AST node for the currently-executing field.
-
#initialize(context:, path:, irep_node:) ⇒ FieldResolutionContext
constructor
A new instance of FieldResolutionContext.
Constructor Details
#initialize(context:, path:, irep_node:) ⇒ FieldResolutionContext
Returns a new instance of FieldResolutionContext.
69 70 71 72 73 |
# File 'lib/graphql/query/context.rb', line 69 def initialize(context:, path:, irep_node:) @context = context @path = path @irep_node = irep_node end |
Instance Attribute Details
#irep_node ⇒ Object (readonly)
Returns the value of attribute irep_node.
67 68 69 |
# File 'lib/graphql/query/context.rb', line 67 def irep_node @irep_node end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
67 68 69 |
# File 'lib/graphql/query/context.rb', line 67 def path @path end |
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error to current field resolution.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/graphql/query/context.rb', line 85 def add_error(error) unless error.is_a?(ExecutionError) raise TypeError, "expected error to be a ExecutionError, but was #{error.class}" end error.ast_node ||= irep_node.ast_node error.path ||= path errors << error nil end |
#ast_node ⇒ GraphQL::Language::Nodes::Field
Returns The AST node for the currently-executing field.
78 79 80 |
# File 'lib/graphql/query/context.rb', line 78 def ast_node @irep_node.ast_node end |