Class: GraphQL::FragmentCache::CacheKeyBuilder
- Inherits:
-
Object
- Object
- GraphQL::FragmentCache::CacheKeyBuilder
- Defined in:
- lib/graphql/fragment_cache/cache_key_builder.rb,
lib/graphql/fragment_cache/rails/cache_key_builder.rb
Overview
Extends key builder to use .expand_cache_key in Rails
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(query:, path:, object: nil, **options) ⇒ CacheKeyBuilder
constructor
A new instance of CacheKeyBuilder.
- #object_key(obj) ⇒ Object
Constructor Details
#initialize(query:, path:, object: nil, **options) ⇒ CacheKeyBuilder
Returns a new instance of CacheKeyBuilder.
66 67 68 69 70 71 72 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 66 def initialize(query:, path:, object: nil, **) @object = object @query = query @schema = query.schema @path = path @options = end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
64 65 66 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 64 def object @object end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
64 65 66 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 64 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
64 65 66 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 64 def query @query end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
64 65 66 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 64 def schema @schema end |
Class Method Details
.call(**options) ⇒ Object
59 60 61 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 59 def call(**) new(**).build end |
Instance Method Details
#build ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 74 def build key_parts = [ GraphQL::FragmentCache.namespace, simple_path_cache_key, implicit_cache_key, object_cache_key ] key_parts .compact .map { |key_part| key_part.tr("/", "-") } .join("/") end |
#object_key(obj) ⇒ Object
159 160 161 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 159 def object_key(obj) obj&._graphql_cache_key end |