Skip to content

Commit 3b22366

Browse files
authored
Merge pull request #160 from Shopify/add-wrapper-around-perform
Add a custom wrapper around #perform
2 parents e476f7c + c43bfc4 commit 3b22366

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/graphql/batch/loader.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,21 @@ def resolve #:nodoc:
6666
return if resolved?
6767
load_keys = queue
6868
@queue = nil
69-
perform(load_keys)
69+
70+
around_perform do
71+
perform(load_keys)
72+
end
73+
7074
check_for_broken_promises(load_keys)
7175
rescue => err
7276
reject_pending_promises(load_keys, err)
7377
end
7478

79+
# Interface to add custom code for purposes such as instrumenting the performance of the loader.
80+
def around_perform
81+
yield
82+
end
83+
7584
# For Promise#sync
7685
def wait #:nodoc:
7786
if executor

lib/graphql/batch/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module GraphQL
22
module Batch
3-
VERSION = "0.5.2"
3+
VERSION = "0.5.3"
44
end
55
end

0 commit comments

Comments
 (0)