graphql-persisted_queries 1.6.0 β†’ 1.6.1

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: 7a8319ef6ac9b60ce31f69b86163c9c77f700b2d663da6ab10018b76c96ebc2f
4
- data.tar.gz: b197af199c9699cda0a7c3c5491d2f22b110b77f61a7632a1982ca3acbc49292
3
+ metadata.gz: fa710e0a1af1fe00953679781bf408f3c78201b67920671f9af36ff57edefcc0
4
+ data.tar.gz: cc46697bf61938af0d4359fb9b5bf4898f3bc5108b4f562f94d3003a857064a6
5
5
  SHA512:
6
- metadata.gz: 2f6f9f3d32aad7d89b263f60701c30f06cba0bb43934fa18360e70ef979c1bdf1f28050859b92788040a600e8d803d850f753383d700243dbdea0b59973bcaf5
7
- data.tar.gz: 5505e5d9b983b8dc2a510dd17fe417eee561bc337da0deb203030b6f0889732ea46b5d76dc9694d5129ddc7538f43467040dcbe907651863b6a26d3c9888a2b3
6
+ metadata.gz: 6028cb87dc1e0c7a78f18f29c7afbff2d2aae46fadbec983d6ebbb217016523a8722f27c993570b914b3fec6cebe0d16ad26e7091844a0e60f4bf0d80217cb11
7
+ data.tar.gz: a0d0dada8b7f34298a69aed43dd988ce077e010866faf33c8d206375ee0cb2f00afed1f0794753983a5b2b01f266888f7988d77a031f33c6f55d2779abd62e35
@@ -23,6 +23,7 @@ jobs:
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
+ "gemfiles/graphql_1_13_16.gemfile",
26
27
  "gemfiles/graphql_2_0_0.gemfile",
27
28
  "gemfiles/graphql_master.gemfile"
28
29
  ]
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.6.1 (2022-11-17)
6
+
7
+ - [PR#60](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/60)
8
+ Handle situations when prepare_ast happens before instrumentation ([@DmitryTsepelev][])
9
+
5
10
  ## 1.6.0 (2022-10-10)
6
11
 
7
12
  - [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][])
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # GraphQL::PersistedQueries
1
+ # GraphQL::PersistedQueries ![](https://ruby-gem-downloads-badge.herokuapp.com/graphql-persisted_queries?type=total)
2
2
 
3
3
  `GraphQL::PersistedQueries` is the implementation of [persisted queries](https://www.apollographql.com/docs/react/api/link/persisted-queries/) for [graphql-ruby](https://github.com/rmosolgo/graphql-ruby). With this plugin your backend will cache all the queries, while frontend will send the full query only when it's not found at the backend storage.
4
4
 
@@ -6,13 +6,6 @@
6
6
  - 🀝**Clients share cached queries** – it's enough to miss cache only once for each unique query
7
7
  - πŸŽ…**Works for clients without persisted query support**
8
8
 
9
-
10
- <p align="center">
11
- <a href="https://evilmartians.com/?utm_source=graphql-ruby-persisted_queries">
12
- <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
13
- </a>
14
- </p>
15
-
16
9
  ## Getting started
17
10
 
18
11
  First of all, install and configure [apollo's persisted queries](https://www.apollographql.com/docs/react/api/link/persisted-queries/) on the front–end side:
@@ -92,6 +85,10 @@ An experimental tracing feature can be enabled by setting `tracing: true` when c
92
85
  > πŸ“– Read more about the gem internals: [Persisted queries in GraphQL:
93
86
  Slim down Apollo requests to your Ruby application](https://evilmartians.com/chronicles/persisted-queries-in-graphql-slim-down-apollo-requests-to-your-ruby-application)
94
87
 
88
+ ## Credits
89
+
90
+ Initially sponsored by [Evil Martians](http://evilmartians.com).
91
+
95
92
  ## Contributing
96
93
 
97
94
  Bug reports and pull requests are welcome on GitHub at https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries.
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "graphql", "~> 1.13.16"
4
+
5
+ gemspec path: "../"
@@ -10,26 +10,14 @@ module GraphQL
10
10
  def before_query(query)
11
11
  return unless query.context[:extensions]
12
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
13
+ query.try_load_document!
14
+ return if query.document || query.query_string
21
15
 
22
16
  query.persisted_query_not_found!
23
17
  query.context.errors << GraphQL::ExecutionError.new(NotFound::MESSAGE)
24
18
  end
25
19
 
26
20
  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
21
  end
34
22
  end
35
23
  end
@@ -5,14 +5,6 @@ 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
8
  def persisted_query_not_found!
17
9
  @persisted_query_not_found = true
18
10
  end
@@ -22,17 +14,29 @@ module GraphQL
22
14
  end
23
15
 
24
16
  def prepare_ast
25
- return super unless @context[:extensions]
17
+ return super if @context[:extensions].nil? || @document
18
+
19
+ try_load_document!
26
20
 
27
21
  super.tap do
28
22
  if @context.errors.any?(&method(:not_found_error?))
29
23
  @context.errors.select!(&method(:not_found_error?))
30
24
  end
31
25
 
32
- resolver.persist(query_string, @document) if @not_loaded_document && query_string
26
+ if @persisted_document_not_found && query_string
27
+ resolver.persist(query_string, @document)
28
+ end
33
29
  end
34
30
  end
35
31
 
32
+ def try_load_document!
33
+ return if @document || @persisted_document_not_found
34
+
35
+ compiled_query_resolver = CompiledQueries::Resolver.new(schema, context[:extensions])
36
+ @document = compiled_query_resolver.fetch
37
+ @persisted_document_not_found = @document.nil?
38
+ end
39
+
36
40
  private
37
41
 
38
42
  def resolver
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module PersistedQueries
5
- VERSION = "1.6.0"
5
+ VERSION = "1.6.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.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-10 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -138,6 +138,7 @@ files:
138
138
  - docs/tracing.md
139
139
  - gemfiles/graphql_1_12_0.gemfile
140
140
  - gemfiles/graphql_1_12_4.gemfile
141
+ - gemfiles/graphql_1_13_16.gemfile
141
142
  - gemfiles/graphql_1_13_7.gemfile
142
143
  - gemfiles/graphql_2_0_0.gemfile
143
144
  - gemfiles/graphql_master.gemfile