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.
133 134 135 136 137 138 139 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 133 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.
131 132 133 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 131 def object @object end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
131 132 133 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 131 def path @path end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
131 132 133 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 131 def query @query end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
131 132 133 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 131 def schema @schema end |
Class Method Details
.call(**options) ⇒ Object
126 127 128 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 126 def call(**) new(**).build end |
Instance Method Details
#build ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 141 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
216 217 218 |
# File 'lib/graphql/fragment_cache/cache_key_builder.rb', line 216 def object_key(obj) obj&._graphql_cache_key end |