Class: GraphQL::Query::Context::FieldResolutionContext
- Inherits:
-
Object
- Object
- GraphQL::Query::Context::FieldResolutionContext
- Extended by:
- Delegate
- 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.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#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:, key:, selection:, parent:, field:, parent_type:) ⇒ FieldResolutionContext
constructor
A new instance of FieldResolutionContext.
- #irep_node ⇒ GraphQL::InternalRepresentation::Node
- #path ⇒ Object
- #spawn(key:, selection:, parent_type:, field:) ⇒ Object
Methods included from Delegate
Constructor Details
#initialize(context:, key:, selection:, parent:, field:, parent_type:) ⇒ FieldResolutionContext
Returns a new instance of FieldResolutionContext.
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/graphql/query/context.rb', line 95 def initialize(context:, key:, selection:, parent:, field:, parent_type:) @context = context @key = key @parent = parent @selection = selection @field = field @parent_type = parent_type # This is needed constantly, so set it ahead of time: @query = context.query @schema = context.schema end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
93 94 95 |
# File 'lib/graphql/query/context.rb', line 93 def field @field end |
#parent_type ⇒ Object (readonly)
Returns the value of attribute parent_type.
93 94 95 |
# File 'lib/graphql/query/context.rb', line 93 def parent_type @parent_type end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
93 94 95 |
# File 'lib/graphql/query/context.rb', line 93 def query @query end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
93 94 95 |
# File 'lib/graphql/query/context.rb', line 93 def schema @schema end |
#selection ⇒ Object (readonly)
Returns the value of attribute selection.
93 94 95 |
# File 'lib/graphql/query/context.rb', line 93 def selection @selection end |
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error to current field resolution.
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/graphql/query/context.rb', line 129 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.
117 118 119 |
# File 'lib/graphql/query/context.rb', line 117 def ast_node @selection.ast_node end |
#irep_node ⇒ GraphQL::InternalRepresentation::Node
122 123 124 |
# File 'lib/graphql/query/context.rb', line 122 def irep_node @selection end |
#path ⇒ Object
107 108 109 |
# File 'lib/graphql/query/context.rb', line 107 def path @path ||= @parent.path.dup << @key end |
#spawn(key:, selection:, parent_type:, field:) ⇒ Object
140 141 142 143 144 145 146 147 148 149 |
# File 'lib/graphql/query/context.rb', line 140 def spawn(key:, selection:, parent_type:, field:) FieldResolutionContext.new( context: @context, parent: self, key: key, selection: selection, parent_type: parent_type, field: field, ) end |