graphql-batch 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/graphql/batch.rb +5 -0
- data/lib/graphql/batch/execution_strategy.rb +1 -1
- data/lib/graphql/batch/loader.rb +9 -0
- data/lib/graphql/batch/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a7998f99327121197626be0735b7af3a016ca5a
|
4
|
+
data.tar.gz: f4a64bc74b428f31cc331bf8c9c7399df048a341
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be04e6e7d48f326f2e5fdfdad8b9c3e42401f2a84e43a5bb420aa329bdf2fe5f0b25a478c2a53c3356858d49522a65d8c8a7aa7386146600fe687fc5d48001bc
|
7
|
+
data.tar.gz: 123332a5424e352958781e69767cc818f9ef66c0b06397ab88ceff309bd58c93775225b99f15e806ca5e1575019dc5ac4ff56c5dfa6b81615a5ade1580047681
|
data/README.md
CHANGED
@@ -46,14 +46,23 @@ class RecordLoader < GraphQL::Batch::Loader
|
|
46
46
|
end
|
47
47
|
```
|
48
48
|
|
49
|
-
Use
|
49
|
+
Use `GraphQL::Batch` as a plugin in your schema (for graphql >= `1.5.0`).
|
50
50
|
|
51
51
|
```ruby
|
52
52
|
MySchema = GraphQL::Schema.define do
|
53
53
|
query MyQueryType
|
54
54
|
|
55
|
-
|
56
|
-
|
55
|
+
use GraphQL::Batch
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
For pre `1.5.0` versions:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
MySchema = GraphQL::Schema.define do
|
63
|
+
query MyQueryType
|
64
|
+
|
65
|
+
GraphQL::Batch.use(self)
|
57
66
|
end
|
58
67
|
```
|
59
68
|
|
data/lib/graphql/batch.rb
CHANGED
@@ -19,6 +19,11 @@ module GraphQL
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
def self.use(schema_defn)
|
23
|
+
schema_defn.instrument(:query, GraphQL::Batch::Setup)
|
24
|
+
schema_defn.lazy_resolve(::Promise, :sync)
|
25
|
+
end
|
26
|
+
|
22
27
|
autoload :ExecutionStrategy, 'graphql/batch/execution_strategy'
|
23
28
|
autoload :MutationExecutionStrategy, 'graphql/batch/mutation_execution_strategy'
|
24
29
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
warn "GraphQL::Batch::ExecutionStrategy is deprecated, instead
|
1
|
+
warn "GraphQL::Batch::ExecutionStrategy is deprecated, instead add `use GraphQL::Batch` in GraphQL::Schema.define"
|
2
2
|
|
3
3
|
module GraphQL::Batch
|
4
4
|
class ExecutionStrategy < GraphQL::Query::SerialExecution
|
data/lib/graphql/batch/loader.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
module GraphQL::Batch
|
2
2
|
class Loader
|
3
|
+
class NoExecutorError < StandardError; end
|
4
|
+
|
3
5
|
def self.for(*group_args)
|
4
6
|
loader_key = [self].concat(group_args)
|
5
7
|
executor = Executor.current
|
8
|
+
|
9
|
+
unless executor
|
10
|
+
raise NoExecutorError, "Cannot create loader without an Executor."\
|
11
|
+
" Wrap the call to `for` with `GraphQL::Batch.batch` or use"\
|
12
|
+
" `GraphQL::Batch::Setup` as a query instrumenter if using with `graphql-ruby`"
|
13
|
+
end
|
14
|
+
|
6
15
|
executor.loaders[loader_key] ||= new(*group_args).tap do |loader|
|
7
16
|
loader.loader_key = loader_key
|
8
17
|
loader.executor = executor
|
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.3.
|
4
|
+
version: 0.3.2
|
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: 2017-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.5.
|
148
|
+
rubygems_version: 2.5.2
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: A query batching executor for the graphql gem
|