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
committerNick Thomas <nick@gitlab.com>2018-02-23 15:36:40 +0000
commitb890b7b7742a32ae2dcfd696c2c44a866bdc385c (patch)
tree4f38311a81701a82b8c25cc6f214f5466faa5016 /spec/support/helpers/graphql_helpers.rb
parent01d8a804f7b92152d89434291ac79c80098a0472 (diff)
downloadgitlab-ce-34754-graphql-start.tar.gz
Convert from GraphQL::Batch to BatchLoader34754-graphql-start
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)