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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1290ae93c3ed819164a80214348eb8539ca1f502d66494c78b67a70442cc377f
|
4
|
+
data.tar.gz: 90bab17ae895c6164ae77da598d7afa3073ca0e0cb6b6f21f848fc4038d71a89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
57
|
-
|
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
|
-
|
60
|
-
|
60
|
+
alias_node = lookup_alias_node(ast_nodes, name)
|
61
|
+
return ::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD unless alias_node
|
61
62
|
|
62
|
-
|
63
|
+
next_field_name = alias_node.name
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
88
|
-
|
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
|
-
|
93
|
-
::GraphQL::Execution::Lookahead::NULL_LOOKAHEAD
|
94
|
-
end
|
95
|
-
end
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
def alias_selections
|
99
|
+
return @alias_selections if defined?(@alias_selections)
|
100
|
+
@alias_selections ||= {}
|
101
|
+
end
|
101
102
|
|
102
|
-
|
103
|
-
|
103
|
+
def lookup_alias_node(nodes, name)
|
104
|
+
return if nodes.empty?
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
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
|
-
|
112
|
-
|
113
|
-
|
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,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
|
-
|
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
|
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.
|
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
|
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
|