graphql-batch 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/graphql-batch.gemspec +1 -1
- data/lib/graphql/batch/executor.rb +25 -1
- data/lib/graphql/batch/promise.rb +4 -0
- data/lib/graphql/batch/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e77963ea5a8725ac853785527d846124905e7df
|
4
|
+
data.tar.gz: 22b03ac3a94f6a790cf1415970eb99c738c3b5e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01003e5050f187156315c06d83386a2851baaaae370900f38b410c0dba9121feaac1ea10027a65a4448e3a7c757a74e639d88662838bd670d38a2a700f29d949
|
7
|
+
data.tar.gz: 102b45b5b6db3d71509d5fa8d9ac1f409d7b29418823493e8ac198cc258245d43bc5c7851f6be71b7b3d34cbe8e19e9bdad90e4f5fa1a8e1720132c4164e4d64
|
data/graphql-batch.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'graphql/batch/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "graphql-batch"
|
8
|
-
spec.version =
|
8
|
+
spec.version = GraphQL::Batch::VERSION
|
9
9
|
spec.authors = ["Dylan Thacker-Smith"]
|
10
10
|
spec.email = ["Dylan.Smith@shopify.com"]
|
11
11
|
|
@@ -9,8 +9,14 @@ module GraphQL::Batch
|
|
9
9
|
|
10
10
|
attr_reader :loaders
|
11
11
|
|
12
|
+
# Set to true when performing a batch query, otherwise, it is false.
|
13
|
+
#
|
14
|
+
# Can be used to detect unbatched queries in an ActiveSupport::Notifications.subscribe block.
|
15
|
+
attr_reader :loading
|
16
|
+
|
12
17
|
def initialize
|
13
18
|
@loaders = {}
|
19
|
+
@loading = false
|
14
20
|
end
|
15
21
|
|
16
22
|
def shift
|
@@ -18,7 +24,7 @@ module GraphQL::Batch
|
|
18
24
|
end
|
19
25
|
|
20
26
|
def tick
|
21
|
-
shift.resolve
|
27
|
+
with_loading(true) { shift.resolve }
|
22
28
|
end
|
23
29
|
|
24
30
|
def wait(promise)
|
@@ -35,5 +41,23 @@ module GraphQL::Batch
|
|
35
41
|
def clear
|
36
42
|
loaders.clear
|
37
43
|
end
|
44
|
+
|
45
|
+
def defer
|
46
|
+
# Since we aren't actually deferring callbacks, we need to set #loading to false so that any queries
|
47
|
+
# that happen in the callback aren't interpreted as being performed in GraphQL::Batch::Loader#perform
|
48
|
+
with_loading(false) { yield }
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
def with_loading(loading)
|
54
|
+
was_loading = @loading
|
55
|
+
begin
|
56
|
+
@loading = loading
|
57
|
+
yield
|
58
|
+
ensure
|
59
|
+
@loading = was_loading
|
60
|
+
end
|
61
|
+
end
|
38
62
|
end
|
39
63
|
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.3
|
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-
|
11
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|