graphql-persisted_queries 0.5.1 → 1.1.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: 248a30a043f26aabeb1f2fb61599b7dc7479a2a90cc1890c4fd7125fb61426e4
4
- data.tar.gz: 6fbb89bf490bcf11c6681cb624d9153bf7c2be2eeb5bdd486407c288056ab494
3
+ metadata.gz: ff010e4d5d11f8e7028d4152a880de6d4503bda6b6e777fbc0e7b3bc19058ac8
4
+ data.tar.gz: 0d213b909ab7668c8248d64ab43c1e80f223d5b46b3d9b3954272728e5b96cec
5
5
  SHA512:
6
- metadata.gz: aea67f0744376a70950feea5a331cefd279679c0bc2ed5786f2d2c3fe1a13a31ea87348213b41a0a6d94e7daf32c02cc08364869bb2a088fa0ec2a451f4be793
7
- data.tar.gz: 458ff6a451faac1fff4e1ce51ad42f9b51bc975270e1666d1730549a726f145acd20ce35ed9d630d62d3ea1c9899e8809c8f755af3d3d53e44af3fe6b30a69d2
6
+ metadata.gz: fc0ec99c3950301f1d23779b7706f24f77b5bbffd4f6df9d167379fc25eff9e6eebeb12296331c9a50972152b9fd7e457262bf6fa8379e2dce6d9e4668cb6e9b
7
+ data.tar.gz: dd09cab2aff3905cd6afca029f16377b963856f160eb9c4730ce64fdc2b8cbce861f402c26f748d38fa1fd466a9af04165d284f9792f33f777ffe5c8e2eaebcb
@@ -0,0 +1,52 @@
1
+ name: RSpec
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+ schedule:
9
+ - cron: "0 10 * * *"
10
+
11
+ jobs:
12
+ rspec:
13
+ runs-on: ubuntu-latest
14
+
15
+ env:
16
+ CI: true
17
+
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7]
22
+ gemfile: [
23
+ "gemfiles/graphql_1_8.gemfile",
24
+ "gemfiles/graphql_1_9.gemfile",
25
+ "gemfiles/graphql_1_10.gemfile",
26
+ "gemfiles/graphql_master.gemfile"
27
+ ]
28
+
29
+ steps:
30
+ - uses: actions/checkout@v2
31
+ - uses: actions/cache@v2
32
+ with:
33
+ path: /home/runner/bundle
34
+ key: bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-${{ hashFiles(matrix.gemfile) }}-${{ hashFiles('**/*.gemspec') }}
35
+ restore-keys: |
36
+ bundle-${{ matrix.ruby }}-${{ matrix.gemfile }}-
37
+ - uses: ruby/setup-ruby@v1
38
+ with:
39
+ ruby-version: ${{ matrix.ruby }}
40
+ - name: Install system deps
41
+ run: |
42
+ sudo apt-get update
43
+ sudo apt-get install libsqlite3-dev
44
+ - name: Bundle install
45
+ run: |
46
+ bundle config path /home/runner/bundle
47
+ bundle config --global gemfile ${{ matrix.gemfile }}
48
+ bundle install
49
+ bundle update
50
+ - name: Run RSpec
51
+ run: |
52
+ bundle exec rake spec
@@ -0,0 +1,21 @@
1
+ name: Rubocop
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7
18
+ - name: Lint Ruby code with RuboCop
19
+ run: |
20
+ bundle install --gemfile gemfiles/graphql_1_10.gemfile --jobs 4 --retry 3
21
+ bundle exec --gemfile gemfiles/graphql_1_10.gemfile rubocop
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.1 (2020-12-03)
6
+
7
+ - [PR#37](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/37) Fix deprecation warnings ([@rbviz][])
8
+
9
+ ## 1.1.0 (2020-11-16)
10
+
11
+ - [PR#36](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/36) Support Ruby 2.7.0 ([@DmitryTsepelev][])
12
+
13
+ ## 1.0.2 (2020-06-29)
14
+
15
+ - [PR#35](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/35) fix args for GraphQL::Query::Result ([@ogidow][])
16
+
17
+ ## 1.0.1 (2020-06-25)
18
+
19
+ - [PR#34](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/34) Return GraphQL::Query::Result when raise error ([@ogidow][])
20
+
21
+ ## 🥳 1.0.0 (2020-03-31)
22
+
23
+ - [PR#30](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/30) **BREAKING CHANGE** Move extenstions to the query context ([@DmitryTsepelev][])
24
+
5
25
  ## 0.5.1 (2020-03-18)
6
26
 
7
27
  - [PR#33](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/33) Support AST analyzers ([@DmitryTsepelev][])
@@ -43,3 +63,5 @@
43
63
  [@DmitryTsepelev]: https://github.com/DmitryTsepelev
44
64
  [@bmorton]: https://github.com/bmorton
45
65
  [@JanStevens]: https://github.com/JanStevens
66
+ [@ogidow]: https://github.com/ogidow
67
+ [@rbviz]: https://github.com/rbviz
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
- # GraphQL::PersistedQueries [![Build Status](https://travis-ci.org/DmitryTsepelev/graphql-ruby-persisted_queries.svg?branch=master)](https://travis-ci.org/DmitryTsepelev/graphql-ruby-persisted_queries)
2
-
1
+ # GraphQL::PersistedQueries
3
2
 
4
3
  `GraphQL::PersistedQueries` is the implementation of [persisted queries](https://github.com/apollographql/apollo-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.
5
4
 
@@ -51,15 +50,16 @@ class GraphqlSchema < GraphQL::Schema
51
50
  end
52
51
  ```
53
52
 
54
- Pass `:extensions` argument to all calls of `GraphqlSchema#execute`, usually it happens in `GraphqlController`, `GraphqlChannel` and tests.
53
+ Pass `:extensions` argument as part of a `context` to all calls of `GraphqlSchema#execute`, usually it happens in `GraphqlController`, `GraphqlChannel` and tests:
55
54
 
56
55
  ```ruby
57
56
  GraphqlSchema.execute(
58
57
  params[:query],
59
58
  variables: ensure_hash(params[:variables]),
60
- context: {},
61
- operation_name: params[:operationName],
62
- extensions: ensure_hash(params[:extensions])
59
+ context: {
60
+ extensions: ensure_hash(params[:extensions])
61
+ },
62
+ operation_name: params[:operationName]
63
63
  )
64
64
  ```
65
65
 
@@ -28,7 +28,14 @@ get "/graphql", to: "graphql#execute"
28
28
  Put the request object to the GraphQL context everywhere you execute GraphQL queries:
29
29
 
30
30
  ```ruby
31
- GraphqlSchema.execute(query, variables: variables, context: { request: request })
31
+ GraphqlSchema.execute(
32
+ query,
33
+ variables: ensure_hash(params[:variables]),
34
+ context: {
35
+ extensions: ensure_hash(params[:extensions]),
36
+ request: request
37
+ }
38
+ )
32
39
  ```
33
40
 
34
41
  Turn the `verify_http_method` option when configuring the plugin to enforce using `POST` requests for performing mutations (otherwise the error `Mutations cannot be performed via HTTP GET` will be returned):
@@ -9,7 +9,7 @@ require "graphql/persisted_queries/builder_helpers"
9
9
  module GraphQL
10
10
  # Plugin definition
11
11
  module PersistedQueries
12
- def self.use(schema_defn, options = {})
12
+ def self.use(schema_defn, **options)
13
13
  schema = schema_defn.is_a?(Class) ? schema_defn : schema_defn.target
14
14
  SchemaPatch.patch(schema)
15
15
 
@@ -23,7 +23,7 @@ module GraphQL
23
23
  schema.persisted_queries_tracing_enabled = options.delete(:tracing)
24
24
 
25
25
  store = options.delete(:store) || :memory
26
- schema.configure_persisted_query_store(store, options)
26
+ schema.configure_persisted_query_store(store, **options)
27
27
  end
28
28
  end
29
29
  end
@@ -7,13 +7,13 @@ module GraphQL
7
7
  module PersistedQueries
8
8
  # Contains factory methods for error handlers
9
9
  module ErrorHandlers
10
- def self.build(handler, options = nil)
10
+ def self.build(handler, **options)
11
11
  if handler.is_a?(ErrorHandlers::BaseErrorHandler)
12
12
  handler
13
13
  elsif handler.is_a?(Proc)
14
14
  build_from_proc(handler)
15
15
  else
16
- build_by_name(handler, options)
16
+ build_by_name(handler, **options)
17
17
  end
18
18
  end
19
19
 
@@ -25,8 +25,8 @@ module GraphQL
25
25
  proc
26
26
  end
27
27
 
28
- def self.build_by_name(name, options)
29
- const_get("#{BuilderHelpers.camelize(name)}ErrorHandler").new(options || {})
28
+ def self.build_by_name(name, **options)
29
+ const_get("#{BuilderHelpers.camelize(name)}ErrorHandler").new(**options)
30
30
  rescue NameError => e
31
31
  raise e.class, "Persisted query error handler for :#{name} haven't been found", e.backtrace
32
32
  end
@@ -5,7 +5,7 @@ module GraphQL
5
5
  module ErrorHandlers
6
6
  # Base class for all error handlers
7
7
  class BaseErrorHandler
8
- def initialize(_options); end
8
+ def initialize(**_options); end
9
9
 
10
10
  def call(_error)
11
11
  raise NotImplementedError
@@ -4,7 +4,7 @@ module GraphQL
4
4
  module PersistedQueries
5
5
  # Resolves multiplex query
6
6
  class MultiplexResolver
7
- def initialize(schema, queries, kwargs)
7
+ def initialize(schema, queries, **kwargs)
8
8
  @schema = schema
9
9
  @queries = queries
10
10
  @kwargs = kwargs
@@ -29,18 +29,20 @@ module GraphQL
29
29
  end
30
30
 
31
31
  def resolve_persisted_query(query_params, pos)
32
- extensions = query_params.delete(:extensions)
32
+ extensions = query_params.dig(:context, :extensions)
33
33
  return unless extensions
34
34
 
35
35
  query_params[:query] = Resolver.new(extensions, @schema).resolve(query_params[:query])
36
36
  rescue Resolver::NotFound, Resolver::WrongHash => e
37
- results[pos] = { "errors" => [{ "message" => e.message }] }
37
+ values = { "errors" => [{ "message" => e.message }] }
38
+ query = GraphQL::Query.new(@schema, query_params[:query])
39
+ results[pos] = GraphQL::Query::Result.new(query: query, values: values)
38
40
  end
39
41
 
40
42
  def perform_multiplex
41
43
  resolve_idx = (0...@queries.count).select { |i| results[i].nil? }
42
44
  multiplex_result = @schema.multiplex_original(
43
- resolve_idx.map { |i| @queries.at(i) }, @kwargs
45
+ resolve_idx.map { |i| @queries.at(i) }, **@kwargs
44
46
  )
45
47
  resolve_idx.each_with_index { |res_i, mult_i| results[res_i] = multiplex_result[mult_i] }
46
48
  end
@@ -19,8 +19,8 @@ module GraphQL
19
19
  attr_reader :persisted_query_store, :hash_generator_proc, :persisted_query_error_handler
20
20
  attr_writer :persisted_queries_tracing_enabled
21
21
 
22
- def configure_persisted_query_store(store, options)
23
- @persisted_query_store = StoreAdapters.build(store, options).tap do |adapter|
22
+ def configure_persisted_query_store(store, **options)
23
+ @persisted_query_store = StoreAdapters.build(store, **options).tap do |adapter|
24
24
  adapter.tracers = tracers if persisted_queries_tracing_enabled?
25
25
  end
26
26
  end
@@ -48,7 +48,7 @@ module GraphQL
48
48
  end
49
49
 
50
50
  def multiplex(queries, **kwargs)
51
- MultiplexResolver.new(self, queries, kwargs).resolve
51
+ MultiplexResolver.new(self, queries, **kwargs).resolve
52
52
  end
53
53
 
54
54
  def tracer(name)
@@ -10,16 +10,16 @@ module GraphQL
10
10
  module PersistedQueries
11
11
  # Contains factory methods for store adapters
12
12
  module StoreAdapters
13
- def self.build(adapter, options = nil)
13
+ def self.build(adapter, **options)
14
14
  if adapter.is_a?(StoreAdapters::BaseStoreAdapter)
15
15
  adapter
16
16
  else
17
- build_by_name(adapter, options)
17
+ build_by_name(adapter, **options)
18
18
  end
19
19
  end
20
20
 
21
- def self.build_by_name(name, options)
22
- const_get("#{BuilderHelpers.camelize(name)}StoreAdapter").new(options || {})
21
+ def self.build_by_name(name, **options)
22
+ const_get("#{BuilderHelpers.camelize(name)}StoreAdapter").new(**options)
23
23
  rescue NameError => e
24
24
  raise e.class, "Persisted query store adapter for :#{name} haven't been found", e.backtrace
25
25
  end
@@ -8,7 +8,7 @@ module GraphQL
8
8
  include GraphQL::Tracing::Traceable
9
9
  attr_writer :tracers
10
10
 
11
- def initialize(_options)
11
+ def initialize(**_options)
12
12
  @name = :base
13
13
  end
14
14
 
@@ -35,7 +35,7 @@ module GraphQL
35
35
 
36
36
  def build_dalli_proc(dalli_client)
37
37
  if dalli_client.is_a?(Hash)
38
- build_dalli_proc(MemcachedClientBuilder.new(dalli_client).build)
38
+ build_dalli_proc(MemcachedClientBuilder.new(**dalli_client).build)
39
39
  elsif dalli_client.is_a?(Proc)
40
40
  dalli_client
41
41
  elsif defined?(::Dalli::Client) && dalli_client.is_a?(::Dalli::Client)
@@ -5,7 +5,7 @@ module GraphQL
5
5
  module StoreAdapters
6
6
  # Memory adapter for storing persisted queries
7
7
  class MemoryStoreAdapter < BaseStoreAdapter
8
- def initialize(_options)
8
+ def initialize(**_options)
9
9
  @storage = {}
10
10
  @name = :memory
11
11
  end
@@ -38,7 +38,7 @@ module GraphQL
38
38
  # rubocop: disable Metrics/PerceivedComplexity
39
39
  def build_redis_proc(redis_client)
40
40
  if redis_client.is_a?(Hash)
41
- build_redis_proc(RedisClientBuilder.new(redis_client).build)
41
+ build_redis_proc(RedisClientBuilder.new(**redis_client).build)
42
42
  elsif redis_client.is_a?(Proc)
43
43
  redis_client
44
44
  elsif defined?(::Redis) && redis_client.is_a?(::Redis)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module PersistedQueries
5
- VERSION = "0.5.1"
5
+ VERSION = "1.1.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: 0.5.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -115,9 +115,10 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".github/workflows/rspec.yml"
119
+ - ".github/workflows/rubocop.yml"
118
120
  - ".gitignore"
119
121
  - ".rubocop.yml"
120
- - ".travis.yml"
121
122
  - CHANGELOG.md
122
123
  - Gemfile
123
124
  - LICENSE.txt
@@ -160,7 +161,7 @@ homepage: https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries
160
161
  licenses:
161
162
  - MIT
162
163
  metadata: {}
163
- post_install_message:
164
+ post_install_message:
164
165
  rdoc_options: []
165
166
  require_paths:
166
167
  - lib
@@ -175,8 +176,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
176
  - !ruby/object:Gem::Version
176
177
  version: '0'
177
178
  requirements: []
178
- rubygems_version: 3.0.3
179
- signing_key:
179
+ rubygems_version: 3.1.2
180
+ signing_key:
180
181
  specification_version: 4
181
182
  summary: Persisted queries for graphql-ruby
182
183
  test_files: []
@@ -1,24 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
-
4
- rvm:
5
- - 2.3
6
- - 2.4
7
- - 2.5
8
- - 2.6
9
- - ruby-head
10
-
11
- gemfile:
12
- - gemfiles/graphql_1_8.gemfile
13
- - gemfiles/graphql_1_9.gemfile
14
- - gemfiles/graphql_1_10.gemfile
15
- - gemfiles/graphql_master.gemfile
16
-
17
-
18
- notifications:
19
- email: false
20
-
21
- matrix:
22
- fast_finish: true
23
- allow_failures:
24
- - rvm: ruby-head