graphql-persisted_queries 1.7.0 → 1.8.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: 430993c73790f83784c3e048a8fa0a4032f2fa5809b725265b5600b6ca8b5a01
4
- data.tar.gz: 10aaa0422835323129d2e771f9bcfa68c4b8d24563ff7b8fb0f341b29dc92dd4
3
+ metadata.gz: f87195c0081c6206d4c47361e560fb3f112cbdbca6dd1135cf2e4c7716cb75c9
4
+ data.tar.gz: fe8df08ab03552a446258ff1dc68e27cb9eb810fa2e20dfa853c208a4e6676f9
5
5
  SHA512:
6
- metadata.gz: c8cf0e07efa3c4a2ea92af6014333c3adc08f1471357b3cc31f1d93779e5af3920e7c71b308bff62f34366211fd5912baadd9780cc2978c9b4185582524f9181
7
- data.tar.gz: f001860c11580ae570e25875f548a167ec878d87545befb39b7ee13a58385e2d2fda86a0919745030b915fed8bd84b3cc6200462c467b320e823cb43a9785047
6
+ metadata.gz: 9a1d306f63ee7491d018c1716c76674effec8b55a3190244ad5843789a018297ad250e7264ee133cec26b32ada813fe28c9861133fc67e4e973bcd3312b8a810
7
+ data.tar.gz: 1cf61a5492364b85bee8a9f7d59293ba3ce5d36ae2c406f47ab6ce8aba4dc25f5a86dcd848cb1e863c4e27a693056fac49668ba2b7aa093ba26c21118ade6f89
@@ -18,13 +18,14 @@ jobs:
18
18
  strategy:
19
19
  fail-fast: false
20
20
  matrix:
21
- ruby: [2.7, '3.0', 3.1]
21
+ ruby: [2.7, '3.0', 3.1, 3.2, 3.3]
22
22
  gemfile: [
23
23
  "gemfiles/graphql_1_12_0.gemfile",
24
24
  "gemfiles/graphql_1_12_4.gemfile",
25
25
  "gemfiles/graphql_1_13_7.gemfile",
26
26
  "gemfiles/graphql_1_13_16.gemfile",
27
- "gemfiles/graphql_2_0_0.gemfile",
27
+ "gemfiles/graphql_2_1_0.gemfile",
28
+ "gemfiles/graphql_2_2_5.gemfile",
28
29
  "gemfiles/graphql_master.gemfile"
29
30
  ]
30
31
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.8.1 (2024-06-01)
6
+
7
+ - [PR#77](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/77)
8
+ Fix serialization of Document (broken by [this change](https://github.com/rmosolgo/graphql-ruby/commit/7de7a1f98d4299abc1fb7deb5ca0ed2190867ab6)) ([@DmitryTsepelev][])
9
+
10
+ ## 1.8.0 (2024-03-31)
11
+
12
+ - [PR#73](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/73)
13
+ Use trace_with instead of instrument for modern versions of graphql ([@DmitryTsepelev][])
14
+
5
15
  ## 1.7.0 (2023-02-02)
6
16
 
7
17
  - [PR#62](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/62)
data/README.md CHANGED
@@ -86,6 +86,8 @@ Since our queries are slim now, we can switch back to HTTP GET, you can find a [
86
86
 
87
87
  [persisted-queries-link](https://www.apollographql.com/docs/react/api/link/persisted-queries/) uses _SHA256_ for building hashes by default. Check out this [guide](docs/hash.md) if you want to override this behavior.
88
88
 
89
+ It is possible to skip some parts of the query lifecycle for cases when query is persisted - read more [here](docs/skip_query_preprocessing.md).
90
+
89
91
  An experimental tracing feature can be enabled by setting `tracing: true` when configuring the plugin. Read more about this feature in the [Tracing guide](docs/tracing.md).
90
92
 
91
93
  > 📖 Read more about the gem internals: [Persisted queries in GraphQL:
@@ -0,0 +1,17 @@
1
+ # Skipping some preprocessing steps
2
+
3
+ It does not make much sense to revalidate persisted query—we did it earlier, so it can be disabled in the `#execute` call:
4
+
5
+ ```ruby
6
+ GraphqlSchema.execute(
7
+ params[:query],
8
+ variables: ensure_hash(params[:variables]),
9
+ context: {
10
+ extensions: ensure_hash(params[:extensions])
11
+ },
12
+ operation_name: params[:operationName],
13
+ validate: params[:query].present?
14
+ )
15
+ ```
16
+
17
+ Moreover, some analyzers can be disabled as well: in order to do that just pass the same check `params[:query].present?` to the context and then add early exit to your analyzers based on this flag.
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 2.1.0"
4
+
5
+ gemspec path: "../"
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 2.2.5"
4
+
5
+ gemspec path: "../"
@@ -7,6 +7,28 @@ module GraphQL
7
7
  class Resolver
8
8
  include GraphQL::PersistedQueries::ResolverHelpers
9
9
 
10
+ # Patch to support custom serialization
11
+ class GraphQL::Language::Parser # rubocop:disable Style/ClassAndModuleChildren
12
+ SEP = "|"
13
+
14
+ def _dump(*)
15
+ [
16
+ @graphql_str,
17
+ JSON.generate("filename": @filename, "max_tokens": @max_tokens, "document": @document)
18
+ ].join(SEP)
19
+ end
20
+
21
+ def self._load(args)
22
+ graphql_str, raw_kwargs = args.split(SEP)
23
+
24
+ new(graphql_str,
25
+ filename: raw_kwargs["filename"],
26
+ max_tokens: raw_kwargs["max_tokens"]).tap do |parser|
27
+ parser.instance_variable_set(:@document, raw_kwargs["document"])
28
+ end
29
+ end
30
+ end
31
+
10
32
  def initialize(schema, extensions)
11
33
  @schema = schema
12
34
  @extensions = extensions
@@ -15,12 +15,31 @@ module GraphQL
15
15
  schema.singleton_class.prepend(SchemaPatch)
16
16
 
17
17
  if compiled_queries
18
- schema.instrument :query, CompiledQueries::Instrumentation
18
+ configure_compiled_queries(schema)
19
19
  else
20
20
  schema.singleton_class.class_eval { alias_method :multiplex_original, :multiplex }
21
21
  schema.singleton_class.prepend(MultiplexPatch)
22
22
  end
23
23
  end
24
+
25
+ private
26
+
27
+ def configure_compiled_queries(schema)
28
+ if graphql_ruby_after_2_2_5?
29
+ schema.trace_with(GraphQL::Tracing::LegacyHooksTrace)
30
+ schema.instance_exec { own_instrumenters[:query] << CompiledQueries::Instrumentation }
31
+ else
32
+ schema.instrument :query, CompiledQueries::Instrumentation
33
+ end
34
+ end
35
+
36
+ def graphql_ruby_after_2_2_5?
37
+ check_graphql_version "> 2.2.5"
38
+ end
39
+
40
+ def check_graphql_version(predicate)
41
+ Gem::Dependency.new("graphql", predicate).match?("graphql", GraphQL::VERSION)
42
+ end
24
43
  end
25
44
 
26
45
  # Patches GraphQL::Schema to override multiplex (not needed for compiled queries)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module PersistedQueries
5
- VERSION = "1.7.0"
5
+ VERSION = "1.8.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-persisted_queries
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-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
@@ -135,12 +135,15 @@ files:
135
135
  - docs/error_handling.md
136
136
  - docs/hash.md
137
137
  - docs/http_cache.md
138
+ - docs/skip_query_preprocessing.md
138
139
  - docs/tracing.md
139
140
  - gemfiles/graphql_1_12_0.gemfile
140
141
  - gemfiles/graphql_1_12_4.gemfile
141
142
  - gemfiles/graphql_1_13_16.gemfile
142
143
  - gemfiles/graphql_1_13_7.gemfile
143
144
  - gemfiles/graphql_2_0_0.gemfile
145
+ - gemfiles/graphql_2_1_0.gemfile
146
+ - gemfiles/graphql_2_2_5.gemfile
144
147
  - gemfiles/graphql_master.gemfile
145
148
  - graphql-persisted_queries.gemspec
146
149
  - lib/graphql/persisted_queries.rb
@@ -189,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
192
  - !ruby/object:Gem::Version
190
193
  version: '0'
191
194
  requirements: []
192
- rubygems_version: 3.4.1
195
+ rubygems_version: 3.4.6
193
196
  signing_key:
194
197
  specification_version: 4
195
198
  summary: Persisted queries for graphql-ruby