class GraphQL::Query::Context

It delegates ‘[]` to the hash that’s passed to ‘GraphQL::Query#initialize`.
Expose some query-specific info to field resolve functions.

def [](key)

Lookup `key` from the hash passed to {Schema#execute} as `context:`
def [](key)
  @values[key]
end

def []=(key, value)

Reassign `key` to the hash passed to {Schema#execute} as `context:`
def []=(key, value)
  @values[key] = value
end

def ast_node

Returns:
  • (GraphQL::Language::Nodes::Field) - The AST node for the currently-executing field
def ast_node
  @irep_node.ast_node
end

def execution_strategy=(new_strategy)

def execution_strategy=(new_strategy)
  # GraphQL::Batch re-assigns this value but it was previously not used
  # (ExecutionContext#strategy was used instead)
  # now it _is_ used, but it breaks GraphQL::Batch tests
  @execution_strategy ||= new_strategy
end

def initialize(query:, values:)

Parameters:
  • values (Hash) -- A hash of arbitrary values which will be accessible at query-time
  • query (GraphQL::Query) -- the query who owns this context
def initialize(query:, values:)
  @query = query
  @schema = query.schema
  @values = values || {}
  @errors = []
  @path = []
end

def spawn(key:, selection:, parent_type:, field:)

def spawn(key:, selection:, parent_type:, field:)
  FieldResolutionContext.new(
    context: self,
    path: path + [key],
    selection: selection,
    parent_type: parent_type,
    field: field,
  )
end

def warden

Returns:
  • (GraphQL::Schema::Warden) -
def warden
  @warden ||= @query.warden
end