summaryrefslogtreecommitdiff
path: root/spec/support/helpers/graphql_helpers.rb
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-02-23 15:36:40 +0000
committerBob Van Landuyt <bob@vanlanduyt.co>2018-06-05 20:47:42 +0200
commit287c34ca1f9af4e395493c99623af8437f82d919 (patch)
treea2748dc20c4a159d93564a42dddec7e768e22a43 /spec/support/helpers/graphql_helpers.rb
parent9c6c17cbcdb8bf8185fc1b873dcfd08f723e4df5 (diff)
downloadgitlab-ce-287c34ca1f9af4e395493c99623af8437f82d919.tar.gz
Convert from GraphQL::Batch to BatchLoader
Diffstat (limited to 'spec/support/helpers/graphql_helpers.rb')
-rw-r--r--spec/support/helpers/graphql_helpers.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 5bb2cf9dd9e..1eaa7603af0 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -4,20 +4,17 @@ module GraphqlHelpers
kls[name].call(obj, args, ctx)
end
- # Runs a block inside a GraphQL::Batch wrapper
+ # Runs a block inside a BatchLoader::Executor wrapper
def batch(max_queries: nil, &blk)
wrapper = proc do
- GraphQL::Batch.batch do
- result = yield
-
- if result.is_a?(Array)
- Promise.all(result)
- else
- result
- end
+ begin
+ BatchLoader::Executor.ensure_current
+ blk.call
+ ensure
+ BatchLoader::Executor.clear_current
end
end
-
+
if max_queries
result = nil
expect { result = wrapper.call }.not_to exceed_query_limit(max_queries)