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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bfa918397c9799aca7a3ac30e4031c7f57ad472c
4
- data.tar.gz: 540ea8eba74692bdf2e10cf1561e9d26b1cff52b
3
+ metadata.gz: 4e77963ea5a8725ac853785527d846124905e7df
4
+ data.tar.gz: 22b03ac3a94f6a790cf1415970eb99c738c3b5e7
5
5
  SHA512:
6
- metadata.gz: 3ec623bdc6aa34b85246b338f2a61710f57e2d76b8a3c1b0f502848b2e89b8e54373958db073e48f52843dbdd95a10da07ef54767f50f1f86d9d51dae4ccd80f
7
- data.tar.gz: 7f396d708a3a4d0fa96ce32db63d4788b442b0390b91baa97ab9972f02de39c8c0508ad91e64cd6fa964cb80e6268d6aeabb8d335b4e3ed95835e1f50f66a211
6
+ metadata.gz: 01003e5050f187156315c06d83386a2851baaaae370900f38b410c0dba9121feaac1ea10027a65a4448e3a7c757a74e639d88662838bd670d38a2a700f29d949
7
+ data.tar.gz: 102b45b5b6db3d71509d5fa8d9ac1f409d7b29418823493e8ac198cc258245d43bc5c7851f6be71b7b3d34cbe8e19e9bdad90e4f5fa1a8e1720132c4164e4d64
@@ -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 = Graphql::Batch::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
@@ -3,5 +3,9 @@ module GraphQL::Batch
3
3
  def wait
4
4
  Executor.current.wait(self)
5
5
  end
6
+
7
+ def defer
8
+ Executor.current.defer { super }
9
+ end
6
10
  end
7
11
  end
@@ -1,5 +1,5 @@
1
- module Graphql
1
+ module GraphQL
2
2
  module Batch
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
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.2.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-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql