graphql-fragment_cache 1.9.0 → 1.11.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: 7232944f544614a7b67e6efea2048a31b4d7ea219ef9785a55491c564be7a3c8
4
- data.tar.gz: 7249e56428dc4ff290182f10d519a442bd1bcfb85dc8f4d328dac42067a8f2e9
3
+ metadata.gz: 66fc20ed7d15e85c1d4ce2890d6b28c368a75e3e06ef69ff186470b5a0953567
4
+ data.tar.gz: 4d0d3f12716b8d4d5be627411121cbdba2d067991ea1d6874f3b2891f2636a4a
5
5
  SHA512:
6
- metadata.gz: f5102cb286a4a4acdd2b3c323329d9cf9b43ddec005776e5d0e4c342314d25faf52a71bfeba21d99f5316f4f743b598b15549f498c5004a14132ba4fc95f9b7e
7
- data.tar.gz: 0fb760a419d58c9ab8488fd8464c69cbc740c9bc9f4d55b80ee527f22e6cd0f9a87ae5cff4db3b42c5636b45c7d76bbe5924e929359be6e904a9fcd83f79a781
6
+ metadata.gz: 5758f73fc04e6e63246b6d21899891220f4e7a7733561a72b6b652a26a6f7bd602425d95d14d2711f15a90865caf907d78244c253243541fd414fa59c93c4954
7
+ data.tar.gz: bea6d191cdaba4f7b5ed13250c1d5aaec02e0aafbd44cc8b9d29f5a8dba3718f43db62f683df01d3946ff611603f6dd5a6bba2001344ada4d29143c8aae8291a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.11.0 (2022-02-26)
6
+
7
+ - [PR#79](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/79) Support graphql-ruby 2.0.0 ([@DmitryTsepelev][])
8
+
9
+ ## 1.10.0 (2022-01-30)
10
+
11
+ - [PR#77](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/77) Drop Ruby 2.5 support, add Ruby 3.0 ([@DmitryTsepelev][])
12
+
13
+ ## 1.9.1 (2021-11-28)
14
+
15
+ - [PR#76](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/76) Freeze parser version ([@DmitryTsepelev][])
16
+
5
17
  ## 1.9.0 (2021-08-19)
6
18
 
7
19
  - [PR#71](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/71) Add selection alias to cache keys ([@mretzak][])
data/README.md CHANGED
@@ -17,13 +17,10 @@ end
17
17
 
18
18
  ## Getting started
19
19
 
20
- Add the gem to your Gemfile `gem 'graphql-fragment_cache'` and add the plugin to your schema class (make sure to turn interpreter mode on with AST analysis!):
20
+ Add the gem to your Gemfile `gem 'graphql-fragment_cache'` and add the plugin to your schema class:
21
21
 
22
22
  ```ruby
23
23
  class GraphqSchema < GraphQL::Schema
24
- use GraphQL::Execution::Interpreter
25
- use GraphQL::Analysis::AST
26
-
27
24
  use GraphQL::FragmentCache
28
25
 
29
26
  query QueryType
@@ -69,15 +66,6 @@ class QueryType < BaseObject
69
66
  end
70
67
  ```
71
68
 
72
- If you use [connections](https://graphql-ruby.org/pagination/connection_concepts.html) and plan to cache them—please turn on [brand new](https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/pagination/connections.rb#L5) connections hierarchy in your schema:
73
-
74
- ```ruby
75
- class GraphqSchema < GraphQL::Schema
76
- # ...
77
- use GraphQL::Pagination::Connections
78
- end
79
- ```
80
-
81
69
  ## Cache key generation
82
70
 
83
71
  Cache keys consist of the following parts: namespace, implicit key, and explicit key.
@@ -22,6 +22,8 @@ module GraphQL
22
22
  children = val.selections.empty? ? "" : "[#{val.selections.to_selections_key}]"
23
23
 
24
24
  field_name = val.field.name
25
+ field_alias = val.ast_nodes.map(&:alias).join
26
+ field_name = "#{field_alias}:#{field_name}" unless field_alias.empty?
25
27
 
26
28
  unless val.arguments.empty?
27
29
  args = val.arguments.map { |_1, _2| "#{_1}:#{traverse_argument(_2)}" }.sort.join(",")
@@ -60,7 +62,12 @@ module GraphQL
60
62
  next_field_name = alias_node.name
61
63
 
62
64
  # From https://github.com/rmosolgo/graphql-ruby/blob/1a9a20f3da629e63ea8e5ee8400be82218f9edc3/lib/graphql/execution/lookahead.rb#L91
63
- next_field_defn = get_class_based_field(selected_type, next_field_name)
65
+ next_field_defn =
66
+ if GraphQL::FragmentCache.graphql_ruby_before_2_0?
67
+ get_class_based_field(selected_type, next_field_name)
68
+ else
69
+ @query.get_field(selected_type, next_field_name)
70
+ end
64
71
 
65
72
  alias_selections[name] =
66
73
  if next_field_defn
@@ -22,6 +22,8 @@ module GraphQL
22
22
  children = val.selections.empty? ? "" : "[#{val.selections.to_selections_key}]"
23
23
 
24
24
  field_name = val.field.name
25
+ field_alias = val.ast_nodes.map(&:alias).join
26
+ field_name = "#{field_alias}:#{field_name}" unless field_alias.empty?
25
27
 
26
28
  unless val.arguments.empty?
27
29
  args = val.arguments.map { |_1, _2| "#{_1}:#{traverse_argument(_2)}" }.sort.join(",")
@@ -60,7 +62,12 @@ module GraphQL
60
62
  next_field_name = alias_node.name
61
63
 
62
64
  # From https://github.com/rmosolgo/graphql-ruby/blob/1a9a20f3da629e63ea8e5ee8400be82218f9edc3/lib/graphql/execution/lookahead.rb#L91
63
- next_field_defn = get_class_based_field(selected_type, next_field_name)
65
+ next_field_defn =
66
+ if GraphQL::FragmentCache.graphql_ruby_before_2_0?
67
+ get_class_based_field(selected_type, next_field_name)
68
+ else
69
+ @query.get_field(selected_type, next_field_name)
70
+ end
64
71
 
65
72
  alias_selections[name] =
66
73
  if next_field_defn
@@ -62,7 +62,12 @@ module GraphQL
62
62
  next_field_name = alias_node.name
63
63
 
64
64
  # From https://github.com/rmosolgo/graphql-ruby/blob/1a9a20f3da629e63ea8e5ee8400be82218f9edc3/lib/graphql/execution/lookahead.rb#L91
65
- next_field_defn = get_class_based_field(selected_type, next_field_name)
65
+ next_field_defn =
66
+ if GraphQL::FragmentCache.graphql_ruby_before_2_0?
67
+ get_class_based_field(selected_type, next_field_name)
68
+ else
69
+ @query.get_field(selected_type, next_field_name)
70
+ end
66
71
 
67
72
  alias_selections[name] =
68
73
  if next_field_defn
@@ -23,7 +23,7 @@ module GraphQL
23
23
  end
24
24
 
25
25
  def verify_connections!(context)
26
- return if GraphQL::FragmentCache.graphql_ruby_1_12_or_later? || context.schema.new_connections?
26
+ return if context.schema.new_connections?
27
27
 
28
28
  raise StandardError,
29
29
  "GraphQL::Pagination::Connections should be enabled for connection caching"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module FragmentCache
5
- VERSION = "1.9.0"
5
+ VERSION = "1.11.0"
6
6
  end
7
7
  end
@@ -50,29 +50,20 @@ module GraphQL
50
50
  @cache_store = store
51
51
  end
52
52
 
53
- def graphql_ruby_1_12_or_later?
54
- Gem::Dependency.new("graphql", ">= 1.12.0").match?("graphql", GraphQL::VERSION)
53
+ def graphql_ruby_before_2_0?
54
+ Gem::Dependency.new("graphql", "< 2.0.0").match?("graphql", GraphQL::VERSION)
55
55
  end
56
56
 
57
57
  private
58
58
 
59
59
  def verify_interpreter_and_analysis!(schema_defn)
60
- if graphql_ruby_1_12_or_later?
61
- unless schema_defn.interpreter?
62
- raise StandardError,
63
- "GraphQL::Execution::Execute should not be enabled for fragment caching"
64
- end
65
-
66
- unless schema_defn.analysis_engine == GraphQL::Analysis::AST
67
- raise StandardError,
68
- "GraphQL::Analysis should not be enabled for fragment caching"
69
- end
70
- else
60
+ if graphql_ruby_before_2_0?
71
61
  unless schema_defn.interpreter?
72
62
  raise StandardError,
73
63
  "GraphQL::Execution::Interpreter should be enabled for fragment caching"
74
64
  end
75
65
 
66
+ puts "schema_defn.analysis_engine #{schema_defn.analysis_engine}"
76
67
  unless schema_defn.analysis_engine == GraphQL::Analysis::AST
77
68
  raise StandardError,
78
69
  "GraphQL::Analysis::AST should be enabled for fragment caching"
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.9.0
4
+ version: 1.11.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-08-19 00:00:00.000000000 Z
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.10.8
19
+ version: 1.12.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.10.8
26
+ version: 1.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ruby-next
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: parser
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.0.2.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 3.0.2.0
167
181
  description: Fragment cache for graphql-ruby
168
182
  email:
169
183
  - dmitry.a.tsepelev@gmail.com
@@ -213,14 +227,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
227
  requirements:
214
228
  - - ">="
215
229
  - !ruby/object:Gem::Version
216
- version: '2.5'
230
+ version: '2.6'
217
231
  required_rubygems_version: !ruby/object:Gem::Requirement
218
232
  requirements:
219
233
  - - ">="
220
234
  - !ruby/object:Gem::Version
221
235
  version: '0'
222
236
  requirements: []
223
- rubygems_version: 3.1.2
237
+ rubygems_version: 3.3.7
224
238
  signing_key:
225
239
  specification_version: 4
226
240
  summary: Fragment cache for graphql-ruby