Class: GraphQL::Cache::Field

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

Instance Method Summary collapse

Constructor Details

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

Override #initialize to take a new argument:



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

def initialize(
  *args,
  cache: false,
  **kwargs,
  &block
)
  @cache_config = if cache.is_a? Hash
                    cache
                  else
                    { cache: cache }
                  end
  super(*args, **kwargs, &block)
end

Instance Method Details

#to_graphqlObject



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

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