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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +12 -0
- data/gemfiles/graphql_1_10.gemfile +1 -1
- data/gemfiles/graphql_1_8.gemfile +1 -1
- data/gemfiles/graphql_1_9.gemfile +1 -1
- data/lib/graphql/persisted_queries/store_adapters/redis_store_adapter.rb +8 -3
- data/lib/graphql/persisted_queries/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b56768c7a951fcc1f1ef63fb0bcbe054c900b0a5636579b811f5e858ed1e57b
|
4
|
+
data.tar.gz: 512044a14538d39037d5092860a739646771b5ad4d9deca2df522ce9ba1ef657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
@@ -7,8 +7,13 @@ module GraphQL
|
|
7
7
|
module StoreAdapters
|
8
8
|
# Redis adapter for storing persisted queries
|
9
9
|
class RedisStoreAdapter < BaseStoreAdapter
|
10
|
-
|
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
|
+
@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
|
-
"
|
30
|
+
"#{@namespace}:#{hash}"
|
26
31
|
end
|
27
32
|
|
28
33
|
# rubocop: disable Metrics/MethodLength
|
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.
|
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-
|
11
|
+
date: 2020-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|