Method: GraphQL::Query::Context#initialize

Defined in:
lib/graphql/query/context.rb

#initialize(query:, schema: query.schema, values:, object:) ⇒ Context

Make a new context which delegates key lookup to values

Parameters:

  • the query who owns this context

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



78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/graphql/query/context.rb', line 78

def initialize(query:, schema: query.schema, values:, object:)
  @query = query
  @schema = schema
  @provided_values = values || {}
  @object = object
  # Namespaced storage, where user-provided values are in `nil` namespace:
  @storage = Hash.new { |h, k| h[k] = {} }
  @storage[nil] = @provided_values
  @errors = []
  @path = []
  @value = nil
  @context = self # for SharedMethods TODO delete sharedmethods
  @scoped_context = ScopedContext.new(self)
end