graphql-batch 0.2.0 → 0.2.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 +1 -1
- data/lib/graphql/batch.rb +1 -0
- data/lib/graphql/batch/executor.rb +4 -0
- data/lib/graphql/batch/mutation_execution_strategy.rb +20 -0
- data/lib/graphql/batch/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d4f407789106fb06ee163d087ba8a0b018d0ff5
|
4
|
+
data.tar.gz: 664413f4a7f4776b09d01dd66c23f1a18ab14bc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fc7d6e9e916a0cc7a8e691529749c17b3d47bbdbeadca7b6633c4d9738a36d3ace33892554505e40bfa9ed9246a8d94021771fe276cc45a3bb6ac545eb2e183
|
7
|
+
data.tar.gz: 9fc71751db85879738f84601692f27781a8207564a4e38f1ffa3981d57421df9322943b232925a8e4b3662b4f232d63e002f6b9cc983e148cb764a0db11c2e52
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ Use the batch execution strategy with your schema
|
|
48
48
|
```ruby
|
49
49
|
MySchema = GraphQL::Schema.new(query: MyQueryType)
|
50
50
|
MySchema.query_execution_strategy = GraphQL::Batch::ExecutionStrategy
|
51
|
-
MySchema.mutation_execution_strategy = GraphQL::Batch::
|
51
|
+
MySchema.mutation_execution_strategy = GraphQL::Batch::MutationExecutionStrategy
|
52
52
|
```
|
53
53
|
|
54
54
|
The loader class can be used from the resolve proc 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.
|
data/lib/graphql/batch.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module GraphQL::Batch
|
2
|
+
class MutationExecutionStrategy < GraphQL::Query::SerialExecution
|
3
|
+
class FieldResolution < GraphQL::Query::SerialExecution::FieldResolution
|
4
|
+
def get_finished_value(raw_value)
|
5
|
+
raw_value = GraphQL::Batch::Promise.resolve(raw_value).sync
|
6
|
+
|
7
|
+
context = execution_context.query.context
|
8
|
+
old_execution_strategy = context.execution_strategy
|
9
|
+
begin
|
10
|
+
context.execution_strategy = GraphQL::Batch::ExecutionStrategy.new
|
11
|
+
result = super(raw_value)
|
12
|
+
GraphQL::Batch::Executor.current.wait_all
|
13
|
+
result
|
14
|
+
ensure
|
15
|
+
context.execution_strategy = old_execution_strategy
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
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.2.
|
4
|
+
version: 0.2.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: 2016-03-
|
11
|
+
date: 2016-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/graphql/batch/execution_strategy.rb
|
115
115
|
- lib/graphql/batch/executor.rb
|
116
116
|
- lib/graphql/batch/loader.rb
|
117
|
+
- lib/graphql/batch/mutation_execution_strategy.rb
|
117
118
|
- lib/graphql/batch/promise.rb
|
118
119
|
- lib/graphql/batch/version.rb
|
119
120
|
homepage: https://github.com/Shopify/graphql-batch
|