Class: BulkImports::Common::Extractors::GraphqlExtractor
- Inherits:
-
Object
- Object
- BulkImports::Common::Extractors::GraphqlExtractor
- Defined in:
- lib/bulk_imports/common/extractors/graphql_extractor.rb
Instance Method Summary collapse
- #extract(context) ⇒ Object
-
#initialize(options = {}) ⇒ GraphqlExtractor
constructor
A new instance of GraphqlExtractor.
Constructor Details
#initialize(options = {}) ⇒ GraphqlExtractor
Returns a new instance of GraphqlExtractor.
7 8 9 |
# File 'lib/bulk_imports/common/extractors/graphql_extractor.rb', line 7 def initialize( = {}) @query_klass = [:query] end |
Instance Method Details
#extract(context) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bulk_imports/common/extractors/graphql_extractor.rb', line 11 def extract(context) client = graphql_client(context) query = query_klass.new(context: context) response = client.execute( client.parse(query.to_s), query.variables ).original_hash.deep_dup BulkImports::Pipeline::ExtractedData.new( data: response.dig(*query.data_path), page_info: response.dig(*query.page_info_path) ) end |