Class: AIPP::Downloader::GraphQL

Inherits:
File
  • Object
show all
Defined in:
lib/aipp/downloader/graphql.rb

Overview

Remote file via HTTP

Instance Attribute Summary

Attributes inherited from File

#file

Instance Method Summary collapse

Methods inherited from File

#fetched_file

Constructor Details

#initialize(client:, query:, variables:) ⇒ GraphQL

Returns a new instance of GraphQL.



6
7
8
# File 'lib/aipp/downloader/graphql.rb', line 6

def initialize(client:, query:, variables:)
  @client, @query, @variables = client, query, variables
end

Instance Method Details

#fetch_to(path) ⇒ Object



10
11
12
13
14
15
# File 'lib/aipp/downloader/graphql.rb', line 10

def fetch_to(path)
  @client.query(@query, variables: @variables).tap do |result|
    ::File.write(path.join(fetched_file), result.data.to_h.to_json)
  end
  self
end