graphql-fragment_cache 1.20.0 → 1.20.1

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: d8651322b53be7ad271913264155cb392c3ee945651806765f2a83545c3653dc
4
- data.tar.gz: d80ec3c3e8cea7c27cb595582374e324c4b43571b3f459616d03036cc4411293
3
+ metadata.gz: 1290ae93c3ed819164a80214348eb8539ca1f502d66494c78b67a70442cc377f
4
+ data.tar.gz: 90bab17ae895c6164ae77da598d7afa3073ca0e0cb6b6f21f848fc4038d71a89
5
5
  SHA512:
6
- metadata.gz: e846bc977828d95548c7e763a7eddb75de0e45a0d6cf950dc14973e10aae7df442fb31086874d06faecc01d16176abbb3e67f06a6c3082e53cea333b649d0685
7
- data.tar.gz: 1fa660ff60d1d04b2750e15b0aca8c884a94f5c73e7a079584c2ba76272321c909af3fabb38badbe4d70c7280cc2e5cb2e4fbf70b917b69c0293c4dbbe2045ac
6
+ metadata.gz: ae23bb92581ad0a5527516675ea08ad1668ea98dc6bf63e85411576f5e1321a5db679c0fe24111abdd1db8629577d67bfc5f2223f9cca69c7c94ca3f57cd779a
7
+ data.tar.gz: 07b1772b1862c3a7905894321b17ddf8b3beec3520565e654530b185d269746f8f94c3fa397fa9707bf41afbcb51cc5d6332b81fd2f571d492aab1d05c66529b
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.20.1 (2024-04-03)
6
+
7
+ - [PR#112](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/112) fix tracer deprecation warnings ([@diegofigueroa][])
8
+ - [PR#109](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/109) Remove `Lookahead` patch in modern versions of graphql-ruby ([@DmitryTsepelev][])
9
+
5
10
  ## 1.20.0 (2024-03-02)
6
11
 
7
12
  - [PR#108](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/108) Use trace_with instead of deprecated instrument method ([@camero2734][])
@@ -186,3 +191,4 @@
186
191
  [@KTSCode]: https://github.com/KTSCode
187
192
  [@rince]: https://github.com/rince
188
193
  [@camero2734]: https://github.com/camero2734
194
+ [@diegofigueroa]: https://github.com/diegofigueroa
@@ -53,64 +53,66 @@ module GraphQL
53
53
  alias_selection(name, **kwargs)
54
54
  end
55
55
 
56
- def alias_selection(name, selected_type: @selected_type, arguments: nil)
57
- return alias_selections[name] if alias_selections.key?(name)
56
+ if GraphRubyVersion.before_2_1_4?
57
+ def alias_selection(name, selected_type: @selected_type, arguments: nil)
58
+ return alias_selections[name] if alias_selections.key?(name)
58
59
 
59
- alias_node = lookup_alias_node(ast_nodes, name)
60
- return ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD unless alias_node
60
+ alias_node = lookup_alias_node(ast_nodes, name)
61
+ return ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD unless alias_node
61
62
 
62
- next_field_name = alias_node.name
63
+ next_field_name = alias_node.name
63
64
 
64
- # From https://github.com/rmosolgo/graphql-ruby/blob/1a9a20f3da629e63ea8e5ee8400be82218f9edc3/lib/graphql/execution/lookahead.rb#L91
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
65
+ # From https://github.com/rmosolgo/graphql-ruby/blob/1a9a20f3da629e63ea8e5ee8400be82218f9edc3/lib/graphql/execution/lookahead.rb#L91
66
+ next_field_defn =
67
+ if GraphRubyVersion.before_2_0?
68
+ get_class_based_field(selected_type, next_field_name)
69
+ else
70
+ @query.get_field(selected_type, next_field_name)
71
+ end
71
72
 
72
- alias_selections[name] =
73
- if next_field_defn
74
- next_nodes = []
75
- arguments = @query.arguments_for(alias_node, next_field_defn)
76
- arguments = arguments.is_a?(::GraphQL::Execution::Interpreter::Arguments) ? arguments.keyword_arguments : arguments
77
- @ast_nodes.each do |ast_node|
78
- ast_node.selections.each do |selection|
79
- if GraphQL::FragmentCache.graphql_ruby_after_2_0_13? && GraphQL::FragmentCache.graphql_ruby_before_2_1_4?
80
- find_selected_nodes(selection, next_field_defn, arguments: arguments, matches: next_nodes)
81
- else
82
- find_selected_nodes(selection, next_field_name, next_field_defn, arguments: arguments, matches: next_nodes)
73
+ alias_selections[name] =
74
+ if next_field_defn
75
+ next_nodes = []
76
+ arguments = @query.arguments_for(alias_node, next_field_defn)
77
+ arguments = arguments.is_a?(::GraphQL::Execution::Interpreter::Arguments) ? arguments.keyword_arguments : arguments
78
+ @ast_nodes.each do |ast_node|
79
+ ast_node.selections.each do |selection|
80
+ if GraphRubyVersion.after_2_0_13? && GraphRubyVersion.before_2_1_4?
81
+ find_selected_nodes(selection, next_field_defn, arguments: arguments, matches: next_nodes)
82
+ else
83
+ find_selected_nodes(selection, next_field_name, next_field_defn, arguments: arguments, matches: next_nodes)
84
+ end
83
85
  end
84
86
  end
85
- end
86
87
 
87
- if next_nodes.any?
88
- ::GraphQL::Execution::Lookahead.new(query: @query, ast_nodes: next_nodes, field: next_field_defn, owner_type: selected_type)
88
+ if next_nodes.any?
89
+ ::GraphQL::Execution::Lookahead.new(query: @query, ast_nodes: next_nodes, field: next_field_defn, owner_type: selected_type)
90
+ else
91
+ ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD
92
+ end
89
93
  else
90
94
  ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD
91
95
  end
92
- else
93
- ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD
94
- end
95
- end
96
+ end
96
97
 
97
- def alias_selections
98
- return @alias_selections if defined?(@alias_selections)
99
- @alias_selections ||= {}
100
- end
98
+ def alias_selections
99
+ return @alias_selections if defined?(@alias_selections)
100
+ @alias_selections ||= {}
101
+ end
101
102
 
102
- def lookup_alias_node(nodes, name)
103
- return if nodes.empty?
103
+ def lookup_alias_node(nodes, name)
104
+ return if nodes.empty?
104
105
 
105
- nodes.find do |node|
106
- if node.is_a?(GraphQL::Language::Nodes::FragmentSpread)
107
- node = @query.fragments[node.name]
108
- raise("Invariant: Can't look ahead to nonexistent fragment #{node.name} (found: #{@query.fragments.keys})") unless node
109
- end
106
+ nodes.find do |node|
107
+ if node.is_a?(GraphQL::Language::Nodes::FragmentSpread)
108
+ node = @query.fragments[node.name]
109
+ raise("Invariant: Can't look ahead to nonexistent fragment #{node.name} (found: #{@query.fragments.keys})") unless node
110
+ end
110
111
 
111
- return node if node.alias?(name)
112
- child = lookup_alias_node(node.children, name)
113
- return child if child
112
+ return node if node.alias?(name)
113
+ child = lookup_alias_node(node.children, name)
114
+ return child if child
115
+ end
114
116
  end
115
117
  end
116
118
  end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ using RubyNext
4
+
5
+ module GraphQL
6
+ module FragmentCache
7
+ module GraphRubyVersion
8
+ module_function
9
+
10
+ def before_2_0?
11
+ check_graphql_version "< 2.0.0"
12
+ end
13
+
14
+ def after_2_0_13?
15
+ check_graphql_version "> 2.0.13"
16
+ end
17
+
18
+ def before_2_1_4?
19
+ check_graphql_version "< 2.1.4"
20
+ end
21
+
22
+ def after_2_2_5?
23
+ check_graphql_version "> 2.2.5"
24
+ end
25
+
26
+ def check_graphql_version(predicate)
27
+ Gem::Dependency.new("graphql", predicate).match?("graphql", GraphQL::VERSION)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module FragmentCache
5
- VERSION = "1.20.0"
5
+ VERSION = "1.20.1"
6
6
  end
7
7
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  require "graphql"
4
4
 
5
+ require "graphql/fragment_cache/graphql_ruby_version"
6
+
5
7
  require "graphql/fragment_cache/ext/context_fragments"
6
8
  require "graphql/fragment_cache/ext/graphql_cache_key"
7
9
  require "graphql/fragment_cache/object"
@@ -31,12 +33,11 @@ module GraphQL
31
33
  def use(schema_defn, options = {})
32
34
  verify_interpreter_and_analysis!(schema_defn)
33
35
 
34
- schema_defn.tracer(Schema::Tracer)
35
-
36
- if graphql_ruby_after_2_2_5?
36
+ if GraphRubyVersion.after_2_2_5?
37
37
  schema_defn.trace_with(GraphQL::Tracing::LegacyHooksTrace)
38
38
  schema_defn.instance_exec { own_instrumenters[:query] << Schema::Instrumentation }
39
39
  else
40
+ schema_defn.tracer(Schema::Tracer)
40
41
  schema_defn.instrument(:query, Schema::Instrumentation)
41
42
  end
42
43
 
@@ -64,22 +65,6 @@ module GraphQL
64
65
 
65
66
  alias_method :skip_cache_when_query_has_errors?, :skip_cache_when_query_has_errors
66
67
 
67
- def graphql_ruby_before_2_0?
68
- check_graphql_version "< 2.0.0"
69
- end
70
-
71
- def graphql_ruby_after_2_0_13?
72
- check_graphql_version "> 2.0.13"
73
- end
74
-
75
- def graphql_ruby_before_2_1_4?
76
- check_graphql_version "< 2.1.4"
77
- end
78
-
79
- def graphql_ruby_after_2_2_5?
80
- check_graphql_version "> 2.2.5"
81
- end
82
-
83
68
  private
84
69
 
85
70
  def check_graphql_version(predicate)
@@ -87,7 +72,7 @@ module GraphQL
87
72
  end
88
73
 
89
74
  def verify_interpreter_and_analysis!(schema_defn)
90
- if graphql_ruby_before_2_0?
75
+ if GraphRubyVersion.before_2_0?
91
76
  unless schema_defn.interpreter?
92
77
  raise StandardError,
93
78
  "GraphQL::Execution::Interpreter 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.20.0
4
+ version: 1.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-02 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -204,6 +204,7 @@ files:
204
204
  - lib/graphql/fragment_cache/ext/graphql_cache_key.rb
205
205
  - lib/graphql/fragment_cache/field_extension.rb
206
206
  - lib/graphql/fragment_cache/fragment.rb
207
+ - lib/graphql/fragment_cache/graphql_ruby_version.rb
207
208
  - lib/graphql/fragment_cache/memory_store.rb
208
209
  - lib/graphql/fragment_cache/object.rb
209
210
  - lib/graphql/fragment_cache/object_helpers.rb