Commit 3011b423 authored by George Koltsov's avatar George Koltsov

Update GraphqlExtractor return value to be original hash

- A bug was introduced in
  https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50951
  with addition of `Array.wrap`, which caused return value of
  `GraphqlExtractor`, an enumerator, to be wrapped in an Array,
  which caused exception to be raised in `HashKeyDigger`
- Update return value of `GraphqlExtractor` to be original hash
  instead of wrapping it in an enumerator, there is no need for it
parent 19a72b14
---
title: Update GraphqlExtractor return value to be original hash
merge_request: 51596
author:
type: fixed
...@@ -11,14 +11,10 @@ module BulkImports ...@@ -11,14 +11,10 @@ module BulkImports
def extract(context) def extract(context)
client = graphql_client(context) client = graphql_client(context)
Enumerator.new do |yielder| client.execute(
result = client.execute( client.parse(query.to_s),
client.parse(query.to_s), query.variables(context.entity)
query.variables(context.entity) ).original_hash.deep_dup
)
yielder << result.original_hash.deep_dup
end
end end
private private
......
...@@ -27,11 +27,8 @@ RSpec.describe BulkImports::Common::Extractors::GraphqlExtractor do ...@@ -27,11 +27,8 @@ RSpec.describe BulkImports::Common::Extractors::GraphqlExtractor do
allow(graphql_client).to receive(:execute).and_return(response) allow(graphql_client).to receive(:execute).and_return(response)
end end
it 'returns an enumerator with fetched results' do it 'returns original hash' do
response = subject.extract(context) expect(subject.extract(context)).to eq({ foo: :bar })
expect(response).to be_instance_of(Enumerator)
expect(response.first).to eq({ foo: :bar })
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment