graphql-result_cache 0.1.6 → 0.1.7

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: d1d361dfd45a9552525e8b03e108f86a6189270ed20d4b37918e685b3d0e8efc
4
- data.tar.gz: a489db1d9df11ad98b82781a6e570bdf769c8f86d8388ac7f49f591916b03962
3
+ metadata.gz: 02e5a9de4f745ffd391664a5189555d9b4b156f33d7395f3e6bf9e13a4dc1473
4
+ data.tar.gz: b37e2c2ed1737f55b9b5485f315f49874451bed231eec0c8c26dd9b13cc77889
5
5
  SHA512:
6
- metadata.gz: 0bed904ded2a50739427161d9b66d4e7c446cdb0dbfdacbe38ebae1f4f096d028395d250322a9e25c23a5aa017554e2d5e71bb0b4e79c9b13af2f7bdf84d178d
7
- data.tar.gz: 7f4c54005444a8ceda2551631f11f2ba9b99a4772afb42a55fd0faa854ffb844d5a2ef0605b53c9d1c7e9d443482d0e67e73970816ef2951227e2387c780493c
6
+ metadata.gz: 7d22ade1c0db8835b52b4c676f13ebdb43c1072048b3b608f841334913a30c57ec4b7e62bad9497c672533b03481ec32b05444eb64835f9c85173ea82e9206f0
7
+ data.tar.gz: ff613c81a571657c2e57abf8e3b9dce83375548e94f4d938e024c6071058c64e8c5d3ef14ec416c2e1fc3ca3c4cf1669294563b0f6dedb8fe8b9390d2f78dd1e
data/README.md CHANGED
@@ -105,6 +105,7 @@ GraphQL::ResultCache.configure do |config|
105
105
  config.namespace = "GraphQL:Result" # Cache key namespace
106
106
  config.expires_in = 1.hour # Expire time for the cache, default to 1.hour
107
107
  config.client_hash = -> { Rails.cache.read(:deploy_version) } # GraphQL client package hash key, used in cache key generation, default to nil
108
+ config.except = ->(ctx) { !ctx[:result_cacheable] } # Exception rule, skip the cache while evaluated as true, default to nil
108
109
  config.cache = Rails.cache # The cache object, default to Rails.cache in Rails
109
110
  config.logger = Rails.logger # The Logger, default to Rails.logger in Rails
110
111
  end
@@ -18,6 +18,9 @@ module GraphQL
18
18
  # c.client_hash = -> { Rails.cache.read(:deploy_version) }
19
19
  attr_accessor :client_hash
20
20
 
21
+ # global condition, skip the cache when the value is true, should be a proc.
22
+ attr_accessor :except
23
+
21
24
  # ```
22
25
  # GraphQL::ResultCache.configure do |c|
23
26
  # c.namespace = "GraphQL:Result"
@@ -9,15 +9,23 @@ module GraphQL
9
9
  end
10
10
 
11
11
  def true?
12
+ return false if except?
12
13
  case @if
13
- when Symbol
14
- @obj.send(@if)
15
- when Proc
16
- @if.call(@obj, @args, @ctx)
17
- else
18
- true
14
+ when Symbol
15
+ @obj.send(@if)
16
+ when Proc
17
+ @if.call(@obj, @args, @ctx)
18
+ else
19
+ true
19
20
  end
20
21
  end
22
+
23
+ private
24
+
25
+ def except?
26
+ except = ::GraphQL::ResultCache.except
27
+ except.is_a?(Proc) ? except.call(@ctx) : except
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module ResultCache
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-result_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ying Fu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-26 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler