graphql-result_cache 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c49ef03b8c247374a8b3374471873c4a921dc9fc1b4a4e9e379e2d6f04a61cdd
4
- data.tar.gz: bc292f89395de326e1e84feee22a648fe4a553d7151f0e50dd46a11a234a5adf
3
+ metadata.gz: cca173c02ac7fcc48f7167ecfe2aaf9abfe861bc783da968473cd2d8705b23c3
4
+ data.tar.gz: bfaeb36f3897300d3eb9b7b8d4bd8a5ed0c9396d06b81b0861e2d7290c272a30
5
5
  SHA512:
6
- metadata.gz: 7acd578c4015a18728af29976c44267cd11bf79978db95164c8a01f82bc4aeb2e076080fe87440448b08eea17b4e652ad588711e5c581704cf678ecb78f779f4
7
- data.tar.gz: a072f2778e71b313151a4af9f6683f2ec633c12da1cfd477b2db596f4ab8b8b057f91d4cfbb5e386705eb8d80f817e5d2022afc802cb5a19b3d79e1bfc5827a9
6
+ metadata.gz: 7817142f3cf86c97e42fe3fa11e1d84642bb81b158b36df1f6d3a039ee9284f26d7b838818d720a5ee44683a2d3845211f7206b8d83f8d68662b6e73c3656b44
7
+ data.tar.gz: 1247cc3baa0720659ae71b796c0500b3c166428ac0e62792e63acd054d05565f8d40a2971d42fe2e0b225a3f7ef0409e4d039aabc0ae4dceb355e24786a9de57
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-result_cache (0.1.2)
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.7)
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.16.6
37
+ 1.17.3
@@ -25,5 +25,6 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_dependency 'graphql', '~> 1.9'
27
27
 
28
- spec.required_ruby_version = '>= 2.1.0'
28
+ # graphql v1.9 requires ruby >= 2.2.0
29
+ spec.required_ruby_version = '>= 2.2.0'
29
30
  end
@@ -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&.debug "GraphQL result cache callback called for #{@ctx.path.join('.')}"
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&.info "GraphQL result cache key #{cached ? 'hit' : 'miss'}: #{key}"
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]&.call(result_hash.dig('data', *config[:path]))
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
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module ResultCache
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
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.3
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-07 00:00:00.000000000 Z
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.1.0
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
- rubyforge_project:
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