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

Override #initialize to take a new 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



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

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