graphql-fragment_cache 1.20.0 → 1.20.2

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: d8651322b53be7ad271913264155cb392c3ee945651806765f2a83545c3653dc
4
- data.tar.gz: d80ec3c3e8cea7c27cb595582374e324c4b43571b3f459616d03036cc4411293
3
+ metadata.gz: a8252cb743e4298ff655dac94a07a4f2adfaa2872bc030252a267bf937e207e5
4
+ data.tar.gz: 202261d17d990297574e85e9f8a39a9299b68029ea73ad82ad28a145cbaeb61a
5
5
  SHA512:
6
- metadata.gz: e846bc977828d95548c7e763a7eddb75de0e45a0d6cf950dc14973e10aae7df442fb31086874d06faecc01d16176abbb3e67f06a6c3082e53cea333b649d0685
7
- data.tar.gz: 1fa660ff60d1d04b2750e15b0aca8c884a94f5c73e7a079584c2ba76272321c909af3fabb38badbe4d70c7280cc2e5cb2e4fbf70b917b69c0293c4dbbe2045ac
6
+ metadata.gz: 9e9eefdd11bebc7dac2f9a25ee593785ee69096dfbc483525b9cd550c6f613853adf5caba73d56aa24dffad4815b1101e07559e9555b7699495909cf19ebd56e
7
+ data.tar.gz: 4329bf2d41694d5f8db515220c2bf10eedbce91d46f852014f49f708c5d0fb102ea89463c2c35b66df90628dc24b1b8b1791abe78f10adae5cb93a9174ca7002
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.20.2 (2024-06-01)
6
+
7
+ - [PR#115](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/115) Fix deprecation warning for cache_format_version in Rails 7.1 ([@rince][])
8
+
9
+ ## 1.20.1 (2024-04-03)
10
+
11
+ - [PR#112](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/112) fix tracer deprecation warnings ([@diegofigueroa][])
12
+ - [PR#109](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/109) Remove `Lookahead` patch in modern versions of graphql-ruby ([@DmitryTsepelev][])
13
+
5
14
  ## 1.20.0 (2024-03-02)
6
15
 
7
16
  - [PR#108](https://github.com/DmitryTsepelev/graphql-ruby-fragment_cache/pull/108) Use trace_with instead of deprecated instrument method ([@camero2734][])
@@ -186,3 +195,4 @@
186
195
  [@KTSCode]: https://github.com/KTSCode
187
196
  [@rince]: https://github.com/rince
188
197
  [@camero2734]: https://github.com/camero2734
198
+ [@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
@@ -10,6 +10,11 @@ module GraphQL
10
10
  module Config
11
11
  class << self
12
12
  def store=(store)
13
+ if Rails.version.to_f >= 7.0 && Rails.application
14
+ cache_format_version = Rails.application.config.active_support.cache_format_version
15
+ ActiveSupport::Cache.format_version = cache_format_version if cache_format_version
16
+ end
17
+
13
18
  # Handle both:
14
19
  # store = :memory
15
20
  # store = :mem_cache, ENV['MEMCACHE']
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module FragmentCache
5
- VERSION = "1.20.0"
5
+ VERSION = "1.20.2"
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.2
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-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: sqlite3
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -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