Method: GraphQL::Query::Context#initialize

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

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

Make a new context which delegates key lookup to values

Parameters:

  • query (GraphQL::Query)

    the query who owns this context

  • values (Hash)

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



114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/graphql/query/context.rb', line 114

def initialize(query:, values: , object:)
  @query = query
  @schema = query.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
end