graphql-result_cache 0.1.3 → 0.1.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cca173c02ac7fcc48f7167ecfe2aaf9abfe861bc783da968473cd2d8705b23c3
|
4
|
+
data.tar.gz: bfaeb36f3897300d3eb9b7b8d4bd8a5ed0c9396d06b81b0861e2d7290c272a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7817142f3cf86c97e42fe3fa11e1d84642bb81b158b36df1f6d3a039ee9284f26d7b838818d720a5ee44683a2d3845211f7206b8d83f8d68662b6e73c3656b44
|
7
|
+
data.tar.gz: 1247cc3baa0720659ae71b796c0500b3c166428ac0e62792e63acd054d05565f8d40a2971d42fe2e0b225a3f7ef0409e4d039aabc0ae4dceb355e24786a9de57
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql-result_cache (0.1.
|
4
|
+
graphql-result_cache (0.1.4)
|
5
5
|
graphql (~> 1.9)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
10
|
diff-lcs (1.3)
|
11
|
-
graphql (1.9.
|
11
|
+
graphql (1.9.9)
|
12
12
|
rake (10.5.0)
|
13
13
|
rspec (3.8.0)
|
14
14
|
rspec-core (~> 3.8.0)
|
@@ -34,4 +34,4 @@ DEPENDENCIES
|
|
34
34
|
rspec (~> 3.0)
|
35
35
|
|
36
36
|
BUNDLED WITH
|
37
|
-
1.
|
37
|
+
1.17.3
|
@@ -15,7 +15,7 @@ module GraphQL
|
|
15
15
|
when Proc
|
16
16
|
@value.call(result_hash, @obj, @args, @ctx)
|
17
17
|
end
|
18
|
-
::GraphQL::ResultCache.logger
|
18
|
+
::GraphQL::ResultCache.logger && ::GraphQL::ResultCache.logger.debug("GraphQL result cache callback called for #{@ctx.path.join('.')}")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -11,7 +11,7 @@ module GraphQL
|
|
11
11
|
def add context:, key:, after_process: nil
|
12
12
|
@value[context.query] ||= []
|
13
13
|
cached = cache.exist? key
|
14
|
-
logger
|
14
|
+
logger && logger.info("GraphQL result cache key #{cached ? 'hit' : 'miss'}: #{key}")
|
15
15
|
config_value = { path: context.path, key: key }
|
16
16
|
if cached
|
17
17
|
config_value[:result] = cache.read(key)
|
@@ -44,7 +44,7 @@ module GraphQL
|
|
44
44
|
# result already got from cache, need to amend to response
|
45
45
|
result_hash = result.to_h
|
46
46
|
deep_merge! result_hash, 'data' => config[:path].reverse.inject(config[:result]) { |a, n| {n => a} }
|
47
|
-
config[:after_process]
|
47
|
+
config[:after_process] && config[:after_process].call(dig result_hash, 'data', *config[:path])
|
48
48
|
end
|
49
49
|
end
|
50
50
|
result
|
@@ -62,6 +62,18 @@ module GraphQL
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def dig hash, *path
|
66
|
+
return if path.length.zero?
|
67
|
+
key = path[0]
|
68
|
+
value = hash[key]
|
69
|
+
other_path = path[1..-1]
|
70
|
+
if other_path.length > 0
|
71
|
+
dig value, *other_path if value.is_a?(Hash) || value.is_a?(Array)
|
72
|
+
else
|
73
|
+
value
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
65
77
|
def cache
|
66
78
|
::GraphQL::ResultCache.cache
|
67
79
|
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.
|
4
|
+
version: 0.1.4
|
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-08-
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,15 +108,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
requirements:
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: 2.
|
111
|
+
version: 2.2.0
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.7.8
|
118
|
+
rubygems_version: 3.0.4
|
120
119
|
signing_key:
|
121
120
|
specification_version: 4
|
122
121
|
summary: A result caching plugin for graphql-ruby
|