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
-
#ast_node ⇒ GraphQL::Language::Nodes::Field
The Language::Nodes::Field for the currently-executing field.
-
#errors ⇒ Array<GraphQL::ExecutionError>
readonly
Errors returned during execution.
-
#execution_strategy ⇒ Object
Returns the value of attribute execution_strategy.
-
#query ⇒ GraphQL::Query
readonly
The query whose context this is.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Lookup ‘key` from the hash passed to Schema#execute as `context`.
-
#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`
21 22 23 24 25 |
# File 'lib/graphql/query/context.rb', line 21 def initialize(query:, values:) @query = query @values = values @errors = [] end |
Instance Attribute Details
#ast_node ⇒ GraphQL::Language::Nodes::Field
The Language::Nodes::Field for the currently-executing field.
10 11 12 |
# File 'lib/graphql/query/context.rb', line 10 def ast_node @ast_node end |
#errors ⇒ Array<GraphQL::ExecutionError> (readonly)
Returns errors returned during execution.
13 14 15 |
# File 'lib/graphql/query/context.rb', line 13 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 |
#query ⇒ GraphQL::Query (readonly)
Returns The query whose context this is.
16 17 18 |
# File 'lib/graphql/query/context.rb', line 16 def query @query end |
Instance Method Details
#[](key) ⇒ Object
Lookup ‘key` from the hash passed to Schema#execute as `context`
28 29 30 |
# File 'lib/graphql/query/context.rb', line 28 def [](key) @values[key] end |