diff options
author | Nick Thomas <nick@gitlab.com> | 2018-02-23 15:36:40 +0000 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-06-05 20:47:42 +0200 |
commit | 287c34ca1f9af4e395493c99623af8437f82d919 (patch) | |
tree | a2748dc20c4a159d93564a42dddec7e768e22a43 /spec/support | |
parent | 9c6c17cbcdb8bf8185fc1b873dcfd08f723e4df5 (diff) | |
download | gitlab-ce-287c34ca1f9af4e395493c99623af8437f82d919.tar.gz |
Convert from GraphQL::Batch to BatchLoader
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/helpers/graphql_helpers.rb | 17 |
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) |