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
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#parent_type ⇒ Object
readonly
Returns the value of attribute parent_type.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#selection ⇒ Object
readonly
Returns the value of attribute selection.
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:, selection:, field:, parent_type:) ⇒ FieldResolutionContext
constructor
A new instance of FieldResolutionContext.
- #irep_node ⇒ GraphQL::InternalRepresentation::Node
- #spawn(key:, selection:, parent_type:, field:) ⇒ Object
Constructor Details
#initialize(context:, path:, selection:, field:, parent_type:) ⇒ FieldResolutionContext
Returns a new instance of FieldResolutionContext.
78 79 80 81 82 83 84 |
# File 'lib/graphql/query/context.rb', line 78 def initialize(context:, path:, selection:, field:, parent_type:) @context = context @path = path @selection = selection @field = field @parent_type = parent_type end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
76 77 78 |
# File 'lib/graphql/query/context.rb', line 76 def field @field end |
#parent_type ⇒ Object (readonly)
Returns the value of attribute parent_type.
76 77 78 |
# File 'lib/graphql/query/context.rb', line 76 def parent_type @parent_type end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
76 77 78 |
# File 'lib/graphql/query/context.rb', line 76 def path @path end |
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
76 77 78 |
# File 'lib/graphql/query/context.rb', line 76 def selection @selection end |
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error to current field resolution.
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/graphql/query/context.rb', line 101 def add_error(error) if !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.
89 90 91 |
# File 'lib/graphql/query/context.rb', line 89 def ast_node selection.irep_node.ast_node end |
#irep_node ⇒ GraphQL::InternalRepresentation::Node
94 95 96 |
# File 'lib/graphql/query/context.rb', line 94 def irep_node selection.irep_node end |
#spawn(key:, selection:, parent_type:, field:) ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/graphql/query/context.rb', line 112 def spawn(key:, selection:, parent_type:, field:) FieldResolutionContext.new( context: @context, path: path + [key], selection: selection, parent_type: parent_type, field: field, ) end |