diff options
author | Nick Thomas <nick@gitlab.com> | 2018-02-23 15:36:40 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2018-02-23 15:36:40 +0000 |
commit | b890b7b7742a32ae2dcfd696c2c44a866bdc385c (patch) | |
tree | 4f38311a81701a82b8c25cc6f214f5466faa5016 /spec/support/helpers/graphql_helpers.rb | |
parent | 01d8a804f7b92152d89434291ac79c80098a0472 (diff) | |
download | gitlab-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.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) |