graphql-persisted_queries 1.5.0 → 1.6.0
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 +4 -4
- data/.github/workflows/rspec.yml +1 -2
- data/.github/workflows/rubocop.yml +2 -2
- data/.gitignore +2 -0
- data/CHANGELOG.md +8 -0
- data/gemfiles/{graphql_1_10.gemfile → graphql_2_0_0.gemfile} +1 -1
- data/graphql-persisted_queries.gemspec +1 -1
- data/lib/graphql/persisted_queries/compiled_queries/instrumentation.rb +37 -0
- data/lib/graphql/persisted_queries/compiled_queries/multiplex_patch.rb +1 -1
- data/lib/graphql/persisted_queries/compiled_queries/query_patch.rb +21 -6
- data/lib/graphql/persisted_queries/errors.rb +3 -1
- data/lib/graphql/persisted_queries/schema_patch.rb +7 -4
- data/lib/graphql/persisted_queries/version.rb +1 -1
- data/lib/graphql/persisted_queries.rb +5 -3
- metadata +10 -10
- data/gemfiles/graphql_1_11.gemfile +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a8319ef6ac9b60ce31f69b86163c9c77f700b2d663da6ab10018b76c96ebc2f
|
4
|
+
data.tar.gz: b197af199c9699cda0a7c3c5491d2f22b110b77f61a7632a1982ca3acbc49292
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f6f9f3d32aad7d89b263f60701c30f06cba0bb43934fa18360e70ef979c1bdf1f28050859b92788040a600e8d803d850f753383d700243dbdea0b59973bcaf5
|
7
|
+
data.tar.gz: 5505e5d9b983b8dc2a510dd17fe417eee561bc337da0deb203030b6f0889732ea46b5d76dc9694d5129ddc7538f43467040dcbe907651863b6a26d3c9888a2b3
|
data/.github/workflows/rspec.yml
CHANGED
@@ -20,11 +20,10 @@ jobs:
|
|
20
20
|
matrix:
|
21
21
|
ruby: [2.6, 2.7, 3.0]
|
22
22
|
gemfile: [
|
23
|
-
"gemfiles/graphql_1_10.gemfile",
|
24
|
-
"gemfiles/graphql_1_11.gemfile",
|
25
23
|
"gemfiles/graphql_1_12_0.gemfile",
|
26
24
|
"gemfiles/graphql_1_12_4.gemfile",
|
27
25
|
"gemfiles/graphql_1_13_7.gemfile",
|
26
|
+
"gemfiles/graphql_2_0_0.gemfile",
|
28
27
|
"gemfiles/graphql_master.gemfile"
|
29
28
|
]
|
30
29
|
|
@@ -17,5 +17,5 @@ jobs:
|
|
17
17
|
ruby-version: 2.7
|
18
18
|
- name: Lint Ruby code with RuboCop
|
19
19
|
run: |
|
20
|
-
bundle install --gemfile gemfiles/
|
21
|
-
bundle exec --gemfile gemfiles/
|
20
|
+
bundle install --gemfile gemfiles/graphql_1_12_0.gemfile --jobs 4 --retry 3
|
21
|
+
bundle exec --gemfile gemfiles/graphql_1_12_0.gemfile rubocop
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 1.6.0 (2022-10-10)
|
6
|
+
|
7
|
+
- [PR#57](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/57) Refactor code to use instrumentation instead of a monkey patch, deprecate graphql-ruby 1.10 and 1.11 ([@DmitryTsepelev][])
|
8
|
+
|
9
|
+
## 1.5.1 (2022-09-28)
|
10
|
+
|
11
|
+
- [PR#56](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/56) Support graphql-ruby 2.0.14 ([@DmitryTsepelev][])
|
12
|
+
|
5
13
|
## 1.5.0 (2022-02-10)
|
6
14
|
|
7
15
|
- [PR#53](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/53) Support graphql-ruby 2.0.0 ([@DmitryTsepelev][])
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.required_ruby_version = ">= 2.6"
|
24
24
|
|
25
|
-
spec.add_dependency "graphql", ">= 1.
|
25
|
+
spec.add_dependency "graphql", ">= 1.12"
|
26
26
|
|
27
27
|
spec.add_development_dependency "rspec", "~> 3.9"
|
28
28
|
spec.add_development_dependency "rake", ">= 10.0"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GraphQL
|
4
|
+
module PersistedQueries
|
5
|
+
module CompiledQueries
|
6
|
+
# Instrumentation to support compiled queries
|
7
|
+
module Instrumentation
|
8
|
+
class << self
|
9
|
+
# Actions to perform before the query resolution
|
10
|
+
def before_query(query)
|
11
|
+
return unless query.context[:extensions]
|
12
|
+
|
13
|
+
resolver = resolver_for(query)
|
14
|
+
if (document = resolver.fetch)
|
15
|
+
query.fulfill_document(document)
|
16
|
+
else
|
17
|
+
query.not_loaded_document!
|
18
|
+
end
|
19
|
+
|
20
|
+
return if document || query.query_string
|
21
|
+
|
22
|
+
query.persisted_query_not_found!
|
23
|
+
query.context.errors << GraphQL::ExecutionError.new(NotFound::MESSAGE)
|
24
|
+
end
|
25
|
+
|
26
|
+
def after_query(*); end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def resolver_for(query)
|
31
|
+
CompiledQueries::Resolver.new(query.schema, query.context[:extensions])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -21,7 +21,7 @@ module GraphQL
|
|
21
21
|
|
22
22
|
def add_not_found_error(query)
|
23
23
|
query.context.errors.clear
|
24
|
-
query.context.errors << GraphQL::ExecutionError.new(
|
24
|
+
query.context.errors << GraphQL::ExecutionError.new(NotFound::MESSAGE)
|
25
25
|
GraphQL::Execution::Multiplex::NO_OPERATION
|
26
26
|
end
|
27
27
|
end
|
@@ -5,6 +5,18 @@ module GraphQL
|
|
5
5
|
module CompiledQueries
|
6
6
|
# Patches GraphQL::Query to support compiled queries
|
7
7
|
module QueryPatch
|
8
|
+
def fulfill_document(document)
|
9
|
+
@document = document
|
10
|
+
end
|
11
|
+
|
12
|
+
def not_loaded_document!
|
13
|
+
@not_loaded_document = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def persisted_query_not_found!
|
17
|
+
@persisted_query_not_found = true
|
18
|
+
end
|
19
|
+
|
8
20
|
def persisted_query_not_found?
|
9
21
|
@persisted_query_not_found
|
10
22
|
end
|
@@ -12,13 +24,12 @@ module GraphQL
|
|
12
24
|
def prepare_ast
|
13
25
|
return super unless @context[:extensions]
|
14
26
|
|
15
|
-
@document = resolver.fetch
|
16
|
-
not_loaded_document = @document.nil?
|
17
|
-
|
18
|
-
@persisted_query_not_found = not_loaded_document && query_string.nil?
|
19
|
-
|
20
27
|
super.tap do
|
21
|
-
|
28
|
+
if @context.errors.any?(&method(:not_found_error?))
|
29
|
+
@context.errors.select!(&method(:not_found_error?))
|
30
|
+
end
|
31
|
+
|
32
|
+
resolver.persist(query_string, @document) if @not_loaded_document && query_string
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
@@ -27,6 +38,10 @@ module GraphQL
|
|
27
38
|
def resolver
|
28
39
|
@resolver ||= Resolver.new(@schema, @context[:extensions])
|
29
40
|
end
|
41
|
+
|
42
|
+
def not_found_error?(error)
|
43
|
+
error.message == GraphQL::PersistedQueries::NotFound::MESSAGE
|
44
|
+
end
|
30
45
|
end
|
31
46
|
end
|
32
47
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "graphql/persisted_queries/hash_generator_builder"
|
4
4
|
require "graphql/persisted_queries/resolver"
|
5
5
|
require "graphql/persisted_queries/multiplex_resolver"
|
6
|
+
require "graphql/persisted_queries/compiled_queries/instrumentation"
|
6
7
|
require "graphql/persisted_queries/analyzers/http_method_validator"
|
7
8
|
|
8
9
|
module GraphQL
|
@@ -13,10 +14,12 @@ module GraphQL
|
|
13
14
|
def patch(schema, compiled_queries)
|
14
15
|
schema.singleton_class.prepend(SchemaPatch)
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if compiled_queries
|
18
|
+
schema.instrument :query, CompiledQueries::Instrumentation
|
19
|
+
else
|
20
|
+
schema.singleton_class.class_eval { alias_method :multiplex_original, :multiplex }
|
21
|
+
schema.singleton_class.prepend(MultiplexPatch)
|
22
|
+
end
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -42,9 +42,11 @@ module GraphQL
|
|
42
42
|
raise ArgumentError, "compiled_queries are not supported for graphql-ruby < 1.12.0"
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
GraphQL::
|
47
|
-
|
45
|
+
if Gem::Dependency.new("graphql", "< 2.0.14").match?("graphql", GraphQL::VERSION)
|
46
|
+
GraphQL::Execution::Multiplex.singleton_class.prepend(
|
47
|
+
GraphQL::PersistedQueries::CompiledQueries::MultiplexPatch
|
48
|
+
)
|
49
|
+
end
|
48
50
|
|
49
51
|
GraphQL::Query.prepend(GraphQL::PersistedQueries::CompiledQueries::QueryPatch)
|
50
52
|
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.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-10 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.
|
19
|
+
version: '1.12'
|
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.
|
26
|
+
version: '1.12'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,11 +136,10 @@ files:
|
|
136
136
|
- docs/hash.md
|
137
137
|
- docs/http_cache.md
|
138
138
|
- docs/tracing.md
|
139
|
-
- gemfiles/graphql_1_10.gemfile
|
140
|
-
- gemfiles/graphql_1_11.gemfile
|
141
139
|
- gemfiles/graphql_1_12_0.gemfile
|
142
140
|
- gemfiles/graphql_1_12_4.gemfile
|
143
141
|
- gemfiles/graphql_1_13_7.gemfile
|
142
|
+
- gemfiles/graphql_2_0_0.gemfile
|
144
143
|
- gemfiles/graphql_master.gemfile
|
145
144
|
- graphql-persisted_queries.gemspec
|
146
145
|
- lib/graphql/persisted_queries.rb
|
@@ -148,6 +147,7 @@ files:
|
|
148
147
|
- lib/graphql/persisted_queries/analyzers/http_method_ast_analyzer.rb
|
149
148
|
- lib/graphql/persisted_queries/analyzers/http_method_validator.rb
|
150
149
|
- lib/graphql/persisted_queries/builder_helpers.rb
|
150
|
+
- lib/graphql/persisted_queries/compiled_queries/instrumentation.rb
|
151
151
|
- lib/graphql/persisted_queries/compiled_queries/multiplex_patch.rb
|
152
152
|
- lib/graphql/persisted_queries/compiled_queries/query_patch.rb
|
153
153
|
- lib/graphql/persisted_queries/compiled_queries/resolver.rb
|
@@ -173,7 +173,7 @@ homepage: https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries
|
|
173
173
|
licenses:
|
174
174
|
- MIT
|
175
175
|
metadata: {}
|
176
|
-
post_install_message:
|
176
|
+
post_install_message:
|
177
177
|
rdoc_options: []
|
178
178
|
require_paths:
|
179
179
|
- lib
|
@@ -188,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
191
|
+
rubygems_version: 3.3.7
|
192
|
+
signing_key:
|
193
193
|
specification_version: 4
|
194
194
|
summary: Persisted queries for graphql-ruby
|
195
195
|
test_files: []
|