Class: GraphQL::Query::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(values:) ⇒ Context

Make a new context which delegates key lookup to ‘values`

Parameters:

  • A (Hash)

    hash of arbitrary values which will be accessible at query-time



17
18
19
20
# File 'lib/graphql/query/context.rb', line 17

def initialize(values:)
  @values = values
  @errors = []
end

Instance Attribute Details

#ast_nodeGraphQL::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

#errorsArray<GraphQL::ExecutionError> (readonly)

Returns errors returned during execution.

Returns:



13
14
15
# File 'lib/graphql/query/context.rb', line 13

def errors
  @errors
end

#execution_strategyObject

Returns the value of attribute execution_strategy.



6
7
8
# File 'lib/graphql/query/context.rb', line 6

def execution_strategy
  @execution_strategy
end

Instance Method Details

#[](key) ⇒ Object

Lookup ‘key` from the hash passed to Schema#execute as `context`



23
24
25
# File 'lib/graphql/query/context.rb', line 23

def [](key)
  @values[key]
end