graphql-ruby-fragment_cache icon indicating copy to clipboard operation
graphql-ruby-fragment_cache copied to clipboard

Namespace issue

Open mengqing opened this issue 2 years ago • 1 comments

I understand that you can setup namespace by either

  1. GraphQL::FragmentCache.namespace = "my-prefix"
  2. GraphQL::FragmentCache.configure { |config| config.namespace = "my-prefix" }

It isn't clear to me whether I can set namespace under config.default_options, eg

GraphQL::FragmentCache.configure do |config|
  config.default_options = {
    namespace: "my-prefix"
  }
end

However when I did the above, I got unexpected behaviour where the cache store tries to read the cache key without namespace but write with the namespace as part of the cache key.

Frankly I would expect namespace to be configured as part of the cache store options in which case each individual cache store would handle the namespace

mengqing avatar Oct 13 '21 04:10 mengqing

That's not an expected behavior, I guess it's just a scenario no one used before. By design, default_options are passed to "all cache_fragment calls and cache_fragment: configurations" (see #PR65), namespace is used when cache key is created, it feels like it has nothing to do with the default options.

DmitryTsepelev avatar Oct 19 '21 10:10 DmitryTsepelev

Closing this for now, feel free to reopen 🙂

DmitryTsepelev avatar Oct 19 '22 17:10 DmitryTsepelev