graphql-cache 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile.lock +2 -2
- data/lib/graphql/cache/field.rb +3 -5
- data/lib/graphql/cache/marshal.rb +11 -3
- data/lib/graphql/cache/middleware.rb +1 -1
- data/lib/graphql/cache/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2adeaaafa2b7714c4300a996c5ae17581269dec775277ef4f8b9ddcd90be16b
|
4
|
+
data.tar.gz: aebe2b614ab273b0e49fd7d2e5b997036196e69abd4a0db85a17db7715a084bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f57bcda1e5ae7db5cacacfde797f353b86abf1feaaf7b87a47315a0b945b32969d415ac9ab39eef837c3011f46921d7f3c48534d56741964da5ba599c244086
|
7
|
+
data.tar.gz: 9f9d0afb64baba52c851c1cfaab7142d9419abba765137187ac3853dbf48962214d093a83c73487fa225d99a849ddc1d12ca2612bb99ef4bcbbc67459cd5f5f8
|
data/.travis.yml
CHANGED
@@ -3,10 +3,10 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 2.5.0
|
5
5
|
before_script:
|
6
|
+
- gem install bundler
|
6
7
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
7
8
|
- chmod +x ./cc-test-reporter
|
8
9
|
- ./cc-test-reporter before-build
|
9
|
-
- gem install bundler -v 1.16.1
|
10
10
|
script: bundle exec rspec
|
11
11
|
after_script:
|
12
12
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql-cache (0.2.
|
4
|
+
graphql-cache (0.2.1)
|
5
5
|
graphql (~> 1.8.0.pre10)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
coderay (1.1.2)
|
13
13
|
diff-lcs (1.3)
|
14
14
|
docile (1.3.0)
|
15
|
-
graphql (1.8.0
|
15
|
+
graphql (1.8.0)
|
16
16
|
json (2.1.0)
|
17
17
|
method_source (0.9.0)
|
18
18
|
pry (0.11.3)
|
data/lib/graphql/cache/field.rb
CHANGED
@@ -2,6 +2,8 @@ require 'graphql'
|
|
2
2
|
|
3
3
|
module GraphQL
|
4
4
|
module Cache
|
5
|
+
# Custom field class implementation to allow for
|
6
|
+
# cache config keyword parameters
|
5
7
|
class Field < ::GraphQL::Schema::Field
|
6
8
|
# Override #initialize to take a new argument:
|
7
9
|
def initialize(
|
@@ -10,11 +12,7 @@ module GraphQL
|
|
10
12
|
**kwargs,
|
11
13
|
&block
|
12
14
|
)
|
13
|
-
@cache_config =
|
14
|
-
cache
|
15
|
-
else
|
16
|
-
{ cache: cache }
|
17
|
-
end
|
15
|
+
@cache_config = cache
|
18
16
|
super(*args, **kwargs, &block)
|
19
17
|
end
|
20
18
|
|
@@ -30,14 +30,22 @@ module GraphQL
|
|
30
30
|
|
31
31
|
def write(config)
|
32
32
|
resolved = yield
|
33
|
-
expiry = config[:metadata][:expiry] || GraphQL::Cache.expiry
|
34
|
-
|
35
33
|
document = Builder[resolved].deconstruct
|
36
34
|
|
37
|
-
cache.write(key, document, expires_in: expiry)
|
35
|
+
cache.write(key, document, expires_in: expiry(config))
|
38
36
|
resolved
|
39
37
|
end
|
40
38
|
|
39
|
+
def expiry(config)
|
40
|
+
cache_config = config[:metadata][:cache]
|
41
|
+
|
42
|
+
if cache_config.is_a?(Hash) && cache_config[:expiry]
|
43
|
+
config[:metadata][:cache][:expiry]
|
44
|
+
else
|
45
|
+
GraphQL::Cache.expiry
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
41
49
|
def build(cached, config)
|
42
50
|
Builder[cached].build(config)
|
43
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Kelly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|