Module: GraphQL::Query::Context::SharedMethods
- Included in:
- GraphQL::Query::Context, FieldResolutionContext
- Defined in:
- lib/graphql/query/context.rb
Instance Attribute Summary collapse
-
#object ⇒ Object
The target for field resolution.
-
#skipped ⇒ Boolean
(also: #skipped?)
Were any fields of this selection skipped?.
-
#value ⇒ Hash, ...
readonly
The resolved value for this field.
Instance Method Summary collapse
-
#add_error(error) ⇒ void
Add error at query-level.
-
#backtrace ⇒ GraphQL::Backtrace
The backtrace for this point in query execution.
-
#delete_child(child_ctx) ⇒ Object
private
Remove this child from the result value (used for null propagation and skip).
- #execution_errors ⇒ Object
-
#invalid_null? ⇒ Boolean
True if this selection has been nullified by a null child.
- #lookahead ⇒ Object
-
#skip ⇒ Object
Return this value to tell the runtime to exclude this field from the response altogether.
-
#spawn_child(key:, irep_node:, object:) ⇒ Object
private
Create a child context to use for
key
.
Instance Attribute Details
#object ⇒ Object
Returns The target for field resolution.
9 10 11 |
# File 'lib/graphql/query/context.rb', line 9 def object @object end |
#skipped ⇒ Boolean Also known as: skipped?
Returns were any fields of this selection skipped?.
15 16 17 |
# File 'lib/graphql/query/context.rb', line 15 def skipped @skipped end |
#value ⇒ Hash, ... (readonly)
Returns The resolved value for this field.
12 13 14 |
# File 'lib/graphql/query/context.rb', line 12 def value @value end |
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error at query-level.
56 57 58 59 60 61 62 |
# File 'lib/graphql/query/context.rb', line 56 def add_error(error) if !error.is_a?(ExecutionError) raise TypeError, "expected error to be a ExecutionError, but was #{error.class}" end errors << error nil end |
#backtrace ⇒ GraphQL::Backtrace
Returns The backtrace for this point in query execution.
68 69 70 |
# File 'lib/graphql/query/context.rb', line 68 def backtrace GraphQL::Backtrace.new(self) end |
#delete_child(child_ctx) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Remove this child from the result value (used for null propagation and skip)
35 36 37 |
# File 'lib/graphql/query/context.rb', line 35 def delete_child(child_ctx) @value.delete(child_ctx.key) end |
#execution_errors ⇒ Object
72 73 74 |
# File 'lib/graphql/query/context.rb', line 72 def execution_errors @execution_errors ||= ExecutionErrors.new(self) end |
#invalid_null? ⇒ Boolean
Returns True if this selection has been nullified by a null child.
28 29 30 |
# File 'lib/graphql/query/context.rb', line 28 def invalid_null? @invalid_null end |
#lookahead ⇒ Object
76 77 78 79 80 |
# File 'lib/graphql/query/context.rb', line 76 def lookahead ast_nodes = irep_node.ast_nodes field = irep_node.definition.[:type_class] || raise("Lookahead is only compatible with class-based schemas") Execution::Lookahead.new(query: query, ast_nodes: ast_nodes, field: field) end |
#skip ⇒ Object
Return this value to tell the runtime to exclude this field from the response altogether
23 24 25 |
# File 'lib/graphql/query/context.rb', line 23 def skip GraphQL::Execution::Execute::SKIP end |
#spawn_child(key:, irep_node:, object:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a child context to use for key
43 44 45 46 47 48 49 50 51 |
# File 'lib/graphql/query/context.rb', line 43 def spawn_child(key:, irep_node:, object:) FieldResolutionContext.new( @context, key, irep_node, self, object ) end |