blob: af274ee12992c62e2c85dbc089859251901a0ad0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# frozen_string_literal: true
module BulkImports
module Common
module Extractors
class GraphqlExtractor
def initialize(query)
@query = query[:query]
end
def extract(context)
client = graphql_client(context)
client.execute(
client.parse(query.to_s),
query.variables(context.entity)
).original_hash.deep_dup
end
private
attr_reader :query
def graphql_client(context)
@graphql_client ||= BulkImports::Clients::Graphql.new(
url: context.configuration.url,
token: context.configuration.access_token
)
end
def parsed_query
@parsed_query ||= graphql_client.parse(query.to_s)
end
end
end
end
end
|