Class: GraphQL::Cache::Middleware
- Inherits:
-
Object
- Object
- GraphQL::Cache::Middleware
- Defined in:
- lib/graphql/cache/middleware.rb
Overview
graphql-ruby middleware to wrap resolvers for caching
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#field_args ⇒ Object
Returns the value of attribute field_args.
-
#field_definition ⇒ Object
Returns the value of attribute field_definition.
-
#object ⇒ Object
Returns the value of attribute object.
-
#parent_object ⇒ Object
Returns the value of attribute parent_object.
-
#parent_type ⇒ Object
Returns the value of attribute parent_type.
-
#query_context ⇒ Object
Returns the value of attribute query_context.
Class Method Summary collapse
-
.call(*args, &block) ⇒ Object
Called by graphql-ruby during middleware processing.
Instance Method Summary collapse
-
#call(&block) ⇒ Object
The primary caching entry point.
-
#initialize(parent_type, parent_object, field_definition, field_args, query_context) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(parent_type, parent_object, field_definition, field_args, query_context) ⇒ Middleware
Returns a new instance of Middleware.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/graphql/cache/middleware.rb', line 15 def initialize(parent_type, parent_object, field_definition, field_args, query_context) self.parent_type = parent_type self.parent_object = parent_object self.field_definition = field_definition self.field_args = field_args self.query_context = query_context self.cache = ::GraphQL::Cache.cache return unless parent_object self.object = parent_object.nodes if parent_object.respond_to? :nodes self.object = parent_object.object if parent_object.respond_to? :object end |
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def cache @cache end |
#field_args ⇒ Object
Returns the value of attribute field_args.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def field_args @field_args end |
#field_definition ⇒ Object
Returns the value of attribute field_definition.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def field_definition @field_definition end |
#object ⇒ Object
Returns the value of attribute object.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def object @object end |
#parent_object ⇒ Object
Returns the value of attribute parent_object.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def parent_object @parent_object end |
#parent_type ⇒ Object
Returns the value of attribute parent_type.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def parent_type @parent_type end |
#query_context ⇒ Object
Returns the value of attribute query_context.
7 8 9 |
# File 'lib/graphql/cache/middleware.rb', line 7 def query_context @query_context end |
Class Method Details
.call(*args, &block) ⇒ Object
Called by graphql-ruby during middleware processing
11 12 13 |
# File 'lib/graphql/cache/middleware.rb', line 11 def self.call(*args, &block) new(*args).call(&block) end |