graphql-fragment_cache 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f193c09fd4f7682db9677d754964852e63b7541f2f2fa6d52ea81c8ee8b894fd
4
- data.tar.gz: 328017637ba3c31c9c9af6c6beacdb63e696b13d6065c12d73b02874fb2e29d5
3
+ metadata.gz: 7ad8755b7ad0579ac5b5a663a9c680fd5132ef818f39881b4df5d2a9c09a3d4b
4
+ data.tar.gz: b2132f313316e1f413b2fd07120b3c2a8c0465f66cc6183f32661a8f606074a4
5
5
  SHA512:
6
- metadata.gz: 9fd90630bd8a8505e2fe1a1277b621d22e2c62a23270a87a5487b56fdde57b980859611f80bfeb956915b581e396ee89a75da11548edebddf321ba45a0640e6c
7
- data.tar.gz: 43fa3b1709999e950b8002f7764e0e63bdacd9aa32db644ead959e6cc12c0df8d92c26423300af4aad59139a8a30290a2c82cfe0cc4ff412656c20d4c64919e4
6
+ metadata.gz: 562098e2cfdb77fd07eef41b316fff4b052dcd7fab1b1b05672b5c2c5bf7f3627a7f3f754adae2e6a8c902816f7fb78428c85ab6d9e29395b33bfc1bfab4663e
7
+ data.tar.gz: 309be07ee6de769b32b2d13b258d3e0bd90ee043d4198d10f44c28edcfdbfafc3a52b0f81629fe0b40cc4efb8f8c62b5d801e3c42bec985b8426d205c41e724f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.8.0 (2021-05-13)
6
+
7
+ - [PR#65](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/65) Add default options ([@jeromedalbert][])
8
+
5
9
  ## 1.7.0 (2021-04-30)
6
10
 
7
11
  - [PR#62](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/62) Add a way to force a cache miss ([@jeromedalbert][])
data/README.md CHANGED
@@ -314,6 +314,20 @@ field :post, PostType, cache_fragment: {if: -> { current_user.nil? }} do
314
314
  end
315
315
  ```
316
316
 
317
+ ## Default options
318
+
319
+ You can configure default options that will be passed to all `cache_fragment`
320
+ calls and `cache_fragment:` configurations. For example:
321
+
322
+ ```ruby
323
+ GraphQL::FragmentCache.configure do |config|
324
+ config.default_options = {
325
+ expires_in: 1.hour, # Expire cache keys after 1 hour
326
+ schema_cache_key: nil # Do not clear the cache on each schema change
327
+ }
328
+ end
329
+ ```
330
+
317
331
  ## Renewing the cache
318
332
 
319
333
  You can force the cache to renew during query execution by adding
@@ -22,6 +22,7 @@ module GraphQL
22
22
  class << self
23
23
  attr_reader :cache_store
24
24
  attr_accessor :namespace
25
+ attr_accessor :default_options
25
26
 
26
27
  def use(schema_defn, options = {})
27
28
  verify_interpreter_and_analysis!(schema_defn)
@@ -81,6 +82,7 @@ module GraphQL
81
82
  end
82
83
 
83
84
  self.cache_store = MemoryStore.new
85
+ self.default_options = {}
84
86
  end
85
87
  end
86
88
 
@@ -28,7 +28,8 @@ module GraphQL
28
28
  end
29
29
 
30
30
  def initialize(options:, **_rest)
31
- @cache_options = options || {}
31
+ @cache_options = GraphQL::FragmentCache.default_options.merge(options || {})
32
+ @cache_options[:default_options_merged] = true
32
33
 
33
34
  @context_key = @cache_options.delete(:context_key)
34
35
  @cache_key = @cache_options.delete(:cache_key)
@@ -25,6 +25,10 @@ module GraphQL
25
25
  def cache_fragment(object_to_cache = NO_OBJECT, **options, &block)
26
26
  raise ArgumentError, "Block or argument must be provided" unless block_given? || object_to_cache != NO_OBJECT
27
27
 
28
+ unless options.delete(:default_options_merged)
29
+ options = GraphQL::FragmentCache.default_options.merge(options)
30
+ end
31
+
28
32
  if options.key?(:if) || options.key?(:unless)
29
33
  disabled = options.key?(:if) ? !options.delete(:if) : options.delete(:unless)
30
34
  if disabled
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module FragmentCache
5
- VERSION = "1.7.0"
5
+ VERSION = "1.8.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-fragment_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-30 00:00:00.000000000 Z
11
+ date: 2021-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql