graphql-batch 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/batch/loader.rb +10 -3
- data/lib/graphql/batch/version.rb +1 -1
- 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: b69567be96fe5b00779872cbb3a6d1e14b3d2a28
|
4
|
+
data.tar.gz: cfc2323ef559f92884560f68713b3d9cd41a3017
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423111d4a94fde2835dcfea8cafa234047100d0dd2bc248362b988537ee1dc1c35c86e5924f8db3730d95b09fbb20a49c3dfa3d6e8858271d1ad060a8303e086
|
7
|
+
data.tar.gz: d31cc1b4cddb5db6d1650e51632b26f113e5414c6d9dc44916785b7a5911c0c953e9b1fd476395fea8d9eca2ad502e08a55ead3c7bec994ebdd4059284635980
|
data/lib/graphql/batch/loader.rb
CHANGED
@@ -3,7 +3,7 @@ module GraphQL::Batch
|
|
3
3
|
class NoExecutorError < StandardError; end
|
4
4
|
|
5
5
|
def self.for(*group_args)
|
6
|
-
loader_key =
|
6
|
+
loader_key = loader_key_for(*group_args)
|
7
7
|
executor = Executor.current
|
8
8
|
|
9
9
|
unless executor
|
@@ -18,6 +18,10 @@ module GraphQL::Batch
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def self.loader_key_for(*group_args)
|
22
|
+
[self].concat(group_args)
|
23
|
+
end
|
24
|
+
|
21
25
|
def self.load(key)
|
22
26
|
self.for.load(key)
|
23
27
|
end
|
@@ -40,8 +44,8 @@ module GraphQL::Batch
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def resolve #:nodoc:
|
47
|
+
return if resolved?
|
43
48
|
load_keys = queue
|
44
|
-
return if load_keys.empty?
|
45
49
|
@queue = nil
|
46
50
|
perform(load_keys)
|
47
51
|
check_for_broken_promises(load_keys)
|
@@ -54,13 +58,16 @@ module GraphQL::Batch
|
|
54
58
|
# For Promise#sync
|
55
59
|
def wait #:nodoc:
|
56
60
|
if executor
|
57
|
-
executor.loaders.delete(loader_key)
|
58
61
|
executor.resolve(self)
|
59
62
|
else
|
60
63
|
resolve
|
61
64
|
end
|
62
65
|
end
|
63
66
|
|
67
|
+
def resolved?
|
68
|
+
@queue.nil? || @queue.empty?
|
69
|
+
end
|
70
|
+
|
64
71
|
protected
|
65
72
|
|
66
73
|
# Fulfill the key with provided value, for use in #perform
|
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.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: 2017-
|
11
|
+
date: 2017-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|