Class: GraphQL::Query::Context
- Inherits:
-
Object
- Object
- GraphQL::Query::Context
- Defined in:
- lib/graphql/query/context.rb
Overview
Expose some query-specific info to field resolve functions.
It delegates []
to the hash that's passed to GraphQL::Query#initialize
.
Instance Attribute Summary collapse
-
#errors ⇒ Array<GraphQL::ExecutionError>
readonly
Errors returned during execution.
-
#execution_strategy ⇒ Object
Returns the value of attribute execution_strategy.
-
#irep_node ⇒ GraphQL::InternalRepresentation::Node
The internal representation for this query node.
-
#query ⇒ GraphQL::Query
readonly
The query whose context this is.
- #schema ⇒ GraphQL::Schema readonly
- #warden ⇒ GraphQL::Schema::Mask::Warden readonly
Instance Method Summary collapse
-
#[](key) ⇒ Object
Lookup
key
from the hash passed to Schema#execute ascontext:
. -
#[]=(key, value) ⇒ Object
Reassign
key
to the hash passed to Schema#execute ascontext:
. -
#ast_node ⇒ GraphQL::Language::Nodes::Field
The AST node for the currently-executing field.
-
#initialize(query:, values:) ⇒ Context
constructor
Make a new context which delegates key lookup to
values
.
Constructor Details
#initialize(query:, values:) ⇒ Context
Make a new context which delegates key lookup to values
31 32 33 34 35 36 37 |
# File 'lib/graphql/query/context.rb', line 31 def initialize(query:, values:) @query = query @schema = query.schema @values = values || {} @errors = [] @warden = query.warden end |
Instance Attribute Details
#errors ⇒ Array<GraphQL::ExecutionError> (readonly)
Returns errors returned during execution.
17 18 19 |
# File 'lib/graphql/query/context.rb', line 17 def errors @errors end |
#execution_strategy ⇒ Object
Returns the value of attribute execution_strategy.
6 7 8 |
# File 'lib/graphql/query/context.rb', line 6 def execution_strategy @execution_strategy end |
#irep_node ⇒ GraphQL::InternalRepresentation::Node
Returns The internal representation for this query node.
14 15 16 |
# File 'lib/graphql/query/context.rb', line 14 def irep_node @irep_node end |
#query ⇒ GraphQL::Query (readonly)
Returns The query whose context this is.
20 21 22 |
# File 'lib/graphql/query/context.rb', line 20 def query @query end |
#schema ⇒ GraphQL::Schema (readonly)
23 24 25 |
# File 'lib/graphql/query/context.rb', line 23 def schema @schema end |
#warden ⇒ GraphQL::Schema::Mask::Warden (readonly)
26 27 28 |
# File 'lib/graphql/query/context.rb', line 26 def warden @warden end |
Instance Method Details
#[](key) ⇒ Object
Lookup key
from the hash passed to Schema#execute as context:
40 41 42 |
# File 'lib/graphql/query/context.rb', line 40 def [](key) @values[key] end |
#[]=(key, value) ⇒ Object
Reassign key
to the hash passed to Schema#execute as context:
45 46 47 |
# File 'lib/graphql/query/context.rb', line 45 def []=(key, value) @values[key] = value end |
#ast_node ⇒ GraphQL::Language::Nodes::Field
Returns The AST node for the currently-executing field.
9 10 11 |
# File 'lib/graphql/query/context.rb', line 9 def ast_node irep_node.ast_node end |