Method: GraphQL::Cache::Key#initialize

Defined in:
lib/graphql/cache/key.rb

#initialize(obj, args, type, field) ⇒ Key

Initializes a new Key with the given graphql query context

Parameters:

  • obj (Object)

    The resolved parent object for a field's resolution

  • args (GraphQL::Arguments)

    The internal graphql-ruby wrapper for field arguments

  • type (GraphQL::Schema::Type)

    The type definition of the parent object

  • field (GraphQL::Schema::Field)

    The field being resolved



27
28
29
30
31
32
33
34
35
# File 'lib/graphql/cache/key.rb', line 27

def initialize(obj, args, type, field)
  @object    = obj.object
  @arguments = args
  @type      = type
  @field     = field
  @metadata  = field.[:cache]

  @metadata = { cache: @metadata } unless @metadata.is_a?(Hash)
end