Skip to content

Commit

Permalink
Merge pull request #160 from Shopify/add-wrapper-around-perform
Browse files Browse the repository at this point in the history
Add a custom wrapper around #perform
  • Loading branch information
toneymathews committed May 16, 2023
2 parents e476f7c + c43bfc4 commit 3b22366
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lib/graphql/batch/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,21 @@ def resolve #:nodoc:
return if resolved?
load_keys = queue
@queue = nil
perform(load_keys)

around_perform do
perform(load_keys)
end

check_for_broken_promises(load_keys)
rescue => err
reject_pending_promises(load_keys, err)
end

# Interface to add custom code for purposes such as instrumenting the performance of the loader.
def around_perform
yield
end

# For Promise#sync
def wait #:nodoc:
if executor
Expand Down
2 changes: 1 addition & 1 deletion lib/graphql/batch/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module GraphQL
module Batch
VERSION = "0.5.2"
VERSION = "0.5.3"
end
end

0 comments on commit 3b22366

Please sign in to comment.