Module: GraphQL::ResultCache

Defined in:
lib/graphql/result_cache.rb,
lib/graphql/result_cache/key.rb,
lib/graphql/result_cache/field.rb,
lib/graphql/result_cache/rails.rb,
lib/graphql/result_cache/result.rb,
lib/graphql/result_cache/version.rb,
lib/graphql/result_cache/callback.rb,
lib/graphql/result_cache/condition.rb,
lib/graphql/result_cache/introspection.rb,
lib/graphql/result_cache/context_config.rb,
lib/graphql/result_cache/field_instrument.rb,
lib/graphql/result_cache/introspection/field_type.rb

Defined Under Namespace

Modules: Introspection Classes: Callback, Condition, ContextConfig, Field, FieldInstrument, Key, Rails, Result

Constant Summary collapse

VERSION =
'0.1.7'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheObject

Returns the value of attribute cache.



13
14
15
# File 'lib/graphql/result_cache.rb', line 13

def cache
  @cache
end

.cache_write_optionsObject

Returns the value of attribute cache_write_options.



14
15
16
# File 'lib/graphql/result_cache.rb', line 14

def cache_write_options
  @cache_write_options
end

.client_hashObject

to expire the cache when client hash changes, should be a proc. eg: c.client_hash = -> { Rails.cache.read(:deploy_version) }



19
20
21
# File 'lib/graphql/result_cache.rb', line 19

def client_hash
  @client_hash
end

.exceptObject

global condition, skip the cache when the value is true, should be a proc.



22
23
24
# File 'lib/graphql/result_cache.rb', line 22

def except
  @except
end

.expires_inObject

Returns the value of attribute expires_in.



11
12
13
# File 'lib/graphql/result_cache.rb', line 11

def expires_in
  @expires_in
end

.loggerObject

Returns the value of attribute logger.



15
16
17
# File 'lib/graphql/result_cache.rb', line 15

def logger
  @logger
end

.namespaceObject

Returns the value of attribute namespace.



12
13
14
# File 'lib/graphql/result_cache.rb', line 12

def namespace
  @namespace
end

Class Method Details

.configure {|_self| ... } ⇒ Object

“‘ GraphQL::ResultCache.configure do |c|

c.namespace = "GraphQL:Result"
c.expires_in = 1.hour
c.client_hash = -> { Rails.cache.read(:deploy_version) }

end “‘

Yields:

  • (_self)

Yield Parameters:



31
32
33
# File 'lib/graphql/result_cache.rb', line 31

def configure
  yield self
end

.use(schema_def, options: {}) ⇒ Object



40
41
42
# File 'lib/graphql/result_cache.rb', line 40

def self.use(schema_def, options: {})
  schema_def.instrument(:field, ::GraphQL::ResultCache::FieldInstrument.new)
end