graphql-persisted_queries 0.1.2 → 0.1.3

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: 1e25a22a38ef43e4e30a0c71624a06dcd0999d25c8e83ea130c1861b78e5042c
4
- data.tar.gz: 3da3aa1a7eebabe2dcd9cb82ad95a912f8a55f00fa515e9a321c6128351edc9a
3
+ metadata.gz: 8b56768c7a951fcc1f1ef63fb0bcbe054c900b0a5636579b811f5e858ed1e57b
4
+ data.tar.gz: 512044a14538d39037d5092860a739646771b5ad4d9deca2df522ce9ba1ef657
5
5
  SHA512:
6
- metadata.gz: c9c13316f7aa81fedc29f7f243d260972fac4f39f28ff9ffe934fb4b65f500564a3de1eef7bd94ec114842f4c08f942bfb53268b15e5b6c77382226badec3d6b
7
- data.tar.gz: 6bbae59a3c5ae70551906490c9793e10767d1604aa1ed8326cc8dca3ab233ae16670a18af8131f38c6a9764bf35931db86d1a84ee91d8672a57a0b1bc5e828cc
6
+ metadata.gz: f6359ac33469754e332377d2c5c945cf5ce94c13609efeb603f9d2d6b5db8c08af58c290cec1ca9aa85ff048894ff1edd61a517069348ac2ea6144e7c12f8291
7
+ data.tar.gz: fe4f663992844109589ab001fe394e5c562f75c9eba9b95c6733f6b264a4531657a57952d7b10a30cb7692184592fa46b51cbfc89686dea358f7cbd061de3fd7
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 0.1.3 (2020-01-30)
6
+
7
+ - [PR#15](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/15) Allow optional custom expiration and namespace for Redis store ([@bmorton][])
8
+
5
9
  ## 0.1.2 (2020-01-29)
6
10
 
7
11
  - [PR#13](https://github.com/DmitryTsepelev/graphql-ruby-persisted_queries/pull/13) Support `graphql-ruby` 1.10 ([@DmitryTsepelev][])
@@ -15,3 +19,4 @@
15
19
  - Initial version ([@DmitryTsepelev][])
16
20
 
17
21
  [@DmitryTsepelev]: https://github.com/DmitryTsepelev
22
+ [@bmorton]: https://github.com/bmorton
data/README.md CHANGED
@@ -85,6 +85,18 @@ class GraphqlSchema < GraphQL::Schema
85
85
  end
86
86
  ```
87
87
 
88
+ You can also pass options for expiration and namespace to override the defaults:
89
+
90
+ ```ruby
91
+ class GraphqlSchema < GraphQL::Schema
92
+ use GraphQL::PersistedQueries,
93
+ store: :redis,
94
+ redis_client: { redis_url: ENV["MY_REDIS_URL"] },
95
+ expiration: 172800, # optional, default is 24 hours
96
+ namespace: "my-custom-namespace" # optional, default is "graphql-persisted-query"
97
+ end
98
+ ```
99
+
88
100
  ## Alternative hash functions
89
101
 
90
102
  [apollo-link-persisted-queries](https://github.com/apollographql/apollo-link-persisted-queries) uses _SHA256_ by default so this gem uses it as a default too, but if you want to override it – you can use `:hash_generator` option:
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "graphql", "~> 1.10"
3
+ gem "graphql", "~> 1.10.0"
4
4
 
5
5
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "graphql", "~> 1.8"
3
+ gem "graphql", "~> 1.8.0"
4
4
 
5
5
  gemspec path: "../"
@@ -1,5 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "graphql", "~> 1.9"
3
+ gem "graphql", "~> 1.9.0"
4
4
 
5
5
  gemspec path: "../"
@@ -7,8 +7,13 @@ module GraphQL
7
7
  module StoreAdapters
8
8
  # Redis adapter for storing persisted queries
9
9
  class RedisStoreAdapter < BaseStoreAdapter
10
- def initialize(redis_client:)
10
+ DEFAULT_EXPIRATION = 24 * 60 * 60
11
+ DEFAULT_NAMESPACE = "graphql-persisted-query"
12
+
13
+ def initialize(redis_client:, expiration: nil, namespace: nil)
11
14
  @redis_proc = build_redis_proc(redis_client)
15
+ @expiration = expiration || DEFAULT_EXPIRATION
16
+ @namespace = namespace || DEFAULT_NAMESPACE
12
17
  end
13
18
 
14
19
  def fetch_query(hash)
@@ -16,13 +21,13 @@ module GraphQL
16
21
  end
17
22
 
18
23
  def save_query(hash, query)
19
- @redis_proc.call { |redis| redis.set(key_for(hash), query, ex: 24 * 60 * 60) }
24
+ @redis_proc.call { |redis| redis.set(key_for(hash), query, ex: @expiration) }
20
25
  end
21
26
 
22
27
  private
23
28
 
24
29
  def key_for(hash)
25
- "graphql-persisted-query:#{hash}"
30
+ "#{@namespace}:#{hash}"
26
31
  end
27
32
 
28
33
  # rubocop: disable Metrics/MethodLength
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module PersistedQueries
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
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.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql