Class: GraphQL::Cache::Field

Inherits:
Schema::Field
  • Object
show all
Defined in:
lib/graphql/cache/field.rb

Overview

Custom field class implementation to allow for cache config keyword parameters

Instance Method Summary collapse

Constructor Details

#initialize(*args, cache: false, **kwargs, &block) ⇒ Field

Overriden to take a new cache keyword argument



9
10
11
12
13
14
15
16
17
# File 'lib/graphql/cache/field.rb', line 9

def initialize(
  *args,
  cache: false,
  **kwargs,
  &block
)
  @cache_config = cache
  super(*args, **kwargs, &block)
end

Instance Method Details

#to_graphqlObject

Overriden to provide custom cache config to internal definition



20
21
22
23
24
# File 'lib/graphql/cache/field.rb', line 20

def to_graphql
  field_defn = super # Returns a GraphQL::Field
  field_defn.[:cache] = @cache_config
  field_defn
end