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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1f52d43c7f189fab24b5e00f8b34435e99c03ae23ba4c99dfaa7a94d67271ed
4
- data.tar.gz: 0ceb7b68519b2e1bd0f94686376d26590cebb9697fd50e80272d0770a85c4784
3
+ metadata.gz: 91e74a8bcaef766442554972512d2e294e45e69a694958a3e5d1d21d72d0561c
4
+ data.tar.gz: 9304331994c9b8065e0f531c32eab90dff638e340ed43554d2e3d2188d255a1d
5
5
  SHA512:
6
- metadata.gz: '091fe19e752f10751216374384346e2c4bb0d8fbe35e86248b3584396531ff2775b4732380da5109968b402320ca22e0cc2f1f772ca26f9d12b4b2bfc5a5a049'
7
- data.tar.gz: 6890562c5b66004bf10b886ba6370cf7c544ab796f2e29ac279b49c93003079b1722c068155a168f5ee9f3194b34395a2d26ac2e8e3013cecd6e74db2286d8ad
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 (for graphql >= `1.5.0`).
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 product(ids:)
95
+ def products(ids:)
103
96
  RecordLoader.for(Product).load_many(ids)
104
97
  end
105
98
  ```
@@ -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 Gem::Version.new(GraphQL::VERSION) >= Gem::Version.new('1.9.0.pre3')
21
- require_relative "batch/mutation_field_extension"
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
- schema.mutation.fields.each do |name, f|
24
- field = f.metadata[:type_class]
25
- field.extension(GraphQL::Batch::MutationFieldExtension)
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)
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module Batch
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.1"
4
4
  end
5
5
  end
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.0
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-02-13 00:00:00.000000000 Z
11
+ date: 2019-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql