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_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
11 12 13 |
# File 'lib/graphql/query/context.rb', line 11 def object @object end |
#skipped ⇒ Boolean Also known as: skipped?
Returns were any fields of this selection skipped?
17 18 19 |
# File 'lib/graphql/query/context.rb', line 17 def skipped @skipped end |
#value ⇒ Hash, ... (readonly)
Returns The resolved value for this field
14 15 16 |
# File 'lib/graphql/query/context.rb', line 14 def value @value end |
Instance Method Details
#add_error(error) ⇒ void
This method returns an undefined value.
Add error at query-level.
58 59 60 61 62 63 64 |
# File 'lib/graphql/query/context.rb', line 58 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
70 71 72 |
# File 'lib/graphql/query/context.rb', line 70 def backtrace GraphQL::Backtrace.new(self) end |
#delete(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)
37 38 39 |
# File 'lib/graphql/query/context.rb', line 37 def delete(child_ctx) @value.delete(child_ctx.key) end |
#execution_errors ⇒ Object
74 75 76 |
# File 'lib/graphql/query/context.rb', line 74 def execution_errors @execution_errors ||= ExecutionErrors.new(self) end |
#invalid_null? ⇒ Boolean
Returns True if this selection has been nullified by a null child
30 31 32 |
# File 'lib/graphql/query/context.rb', line 30 def invalid_null? @invalid_null end |
#lookahead ⇒ Object
78 79 80 81 82 |
# File 'lib/graphql/query/context.rb', line 78 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
25 26 27 |
# File 'lib/graphql/query/context.rb', line 25 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
45 46 47 48 49 50 51 52 53 |
# File 'lib/graphql/query/context.rb', line 45 def spawn_child(key:, irep_node:, object:) FieldResolutionContext.new( context: @context, parent: self, object: object, key: key, irep_node: irep_node, ) end |