graphql-batch 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -11
- data/lib/graphql/batch.rb +12 -11
- data/lib/graphql/batch/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: 91e74a8bcaef766442554972512d2e294e45e69a694958a3e5d1d21d72d0561c
|
4
|
+
data.tar.gz: 9304331994c9b8065e0f531c32eab90dff638e340ed43554d2e3d2188d255a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 573581325fe65a14189848de43ebbf73d8affe7160e337c4a199a73e27d62c6073e2a233a51fc30ab278f028bd6258c3d0c2b8cb0521b21fe21c2c96fe82d534
|
7
|
+
data.tar.gz: 4d49402c2de01bfbe3c65637b8701a269d80bd15dc8164d91bb91454414a6c1efec90826fcf5e6dd645f0d575fadea3a74bc4b34d9cf5f49cb98015089532299
|
data/README.md
CHANGED
@@ -48,7 +48,9 @@ class RecordLoader < GraphQL::Batch::Loader
|
|
48
48
|
end
|
49
49
|
```
|
50
50
|
|
51
|
-
Use `GraphQL::Batch` as a plugin in your schema
|
51
|
+
Use `GraphQL::Batch` as a plugin in your schema _after_ specifying the mutation
|
52
|
+
so that `GraphQL::Batch` can extend the mutation fields to clear the cache after
|
53
|
+
they are resolved (for graphql >= `1.5.0`).
|
52
54
|
|
53
55
|
```ruby
|
54
56
|
class MySchema < GraphQL::Schema
|
@@ -69,15 +71,6 @@ MySchema = GraphQL::Schema.define do
|
|
69
71
|
end
|
70
72
|
```
|
71
73
|
|
72
|
-
##### With `1.9.0`'s `Interpreter` runtime
|
73
|
-
|
74
|
-
Add `GraphQL::Batch` _after_ the interpreter, so that `GraphQL::Batch` can detect the interpreter and attach the right integrations:
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
use GraphQL::Execution::Interpreter
|
78
|
-
use GraphQL::Batch
|
79
|
-
```
|
80
|
-
|
81
74
|
#### Field Usage
|
82
75
|
|
83
76
|
The loader class can be used from the resolver for a graphql field by calling `.for` with the grouping arguments to get a loader instance, then call `.load` on that instance with the key to load.
|
@@ -99,7 +92,7 @@ field :products, [Types::Product, null: true], null: false do
|
|
99
92
|
argument :ids, [ID], required: true
|
100
93
|
end
|
101
94
|
|
102
|
-
def
|
95
|
+
def products(ids:)
|
103
96
|
RecordLoader.for(Product).load_many(ids)
|
104
97
|
end
|
105
98
|
```
|
data/lib/graphql/batch.rb
CHANGED
@@ -17,20 +17,21 @@ module GraphQL
|
|
17
17
|
|
18
18
|
def self.use(schema_defn, executor_class: GraphQL::Batch::Executor)
|
19
19
|
schema = schema_defn.target
|
20
|
-
if
|
21
|
-
|
20
|
+
if GraphQL::VERSION >= "1.6.0"
|
21
|
+
instrumentation = GraphQL::Batch::SetupMultiplex.new(schema, executor_class: executor_class)
|
22
|
+
schema_defn.instrument(:multiplex, instrumentation)
|
22
23
|
if schema.mutation
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
if Gem::Version.new(GraphQL::VERSION) >= Gem::Version.new('1.9.0.pre3') &&
|
25
|
+
schema.mutation.metadata[:type_class]
|
26
|
+
require_relative "batch/mutation_field_extension"
|
27
|
+
schema.mutation.fields.each do |name, f|
|
28
|
+
field = f.metadata[:type_class]
|
29
|
+
field.extension(GraphQL::Batch::MutationFieldExtension)
|
30
|
+
end
|
31
|
+
else
|
32
|
+
schema_defn.instrument(:field, instrumentation)
|
26
33
|
end
|
27
34
|
end
|
28
|
-
instrumentation = GraphQL::Batch::SetupMultiplex.new(schema, executor_class: executor_class)
|
29
|
-
schema_defn.instrument(:multiplex, instrumentation)
|
30
|
-
elsif GraphQL::VERSION >= "1.6.0"
|
31
|
-
instrumentation = GraphQL::Batch::SetupMultiplex.new(schema, executor_class: executor_class)
|
32
|
-
schema_defn.instrument(:multiplex, instrumentation)
|
33
|
-
schema_defn.instrument(:field, instrumentation)
|
34
35
|
else
|
35
36
|
instrumentation = GraphQL::Batch::Setup.new(schema, executor_class: executor_class)
|
36
37
|
schema_defn.instrument(:query, instrumentation)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-batch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Thacker-Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|