module GraphQL::Query::Context::SharedMethods
Attributes
@return [Object] The target for field resultion
@return [Boolean] were any fields of this selection skipped?
@return [Boolean] were any fields of this selection skipped?
@return [Hash, Array, String, Integer, Float, Boolean, nil] The resolved value for this field
Public Instance Methods
Add error at query-level. @param error [GraphQL::ExecutionError] an execution error @return [void]
# 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
@example Print the GraphQL
backtrace during field resolution
puts ctx.backtrace
@return [GraphQL::Backtrace] The backtrace for this point in query execution
# File lib/graphql/query/context.rb, line 70 def backtrace GraphQL::Backtrace.new(self) end
Remove this child from the result value (used for null propagation and skip) @api private
# File lib/graphql/query/context.rb, line 37 def delete(child_ctx) @value.delete(child_ctx.key) end
# File lib/graphql/query/context.rb, line 74 def execution_errors @execution_errors ||= ExecutionErrors.new(self) end
@return [Boolean] True if this selection has been nullified by a null child
# File lib/graphql/query/context.rb, line 30 def invalid_null? @invalid_null end
# File lib/graphql/query/context.rb, line 78 def lookahead ast_nodes = irep_node.ast_nodes field = irep_node.definition.metadata[:type_class] || raise("Lookahead is only compatible with class-based schemas") Execution::Lookahead.new(query: query, ast_nodes: ast_nodes, field: field) end
Return this value to tell the runtime to exclude this field from the response altogether
# File lib/graphql/query/context.rb, line 25 def skip GraphQL::Execution::Execute::SKIP end
Create a child context to use for `key` @param key [String, Integer] The key in the response (name or index) @param irep_node [InternalRepresentation::Node] The node being evaluated @api private
# 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