Module: Eco::API::UseCases::GraphQL::Helpers::Base

Includes:
Language::AuxiliarLogger
Included in:
Base, Location::Base
Defined in:
lib/eco/api/usecases/graphql/helpers/base.rb

Instance Attribute Summary collapse

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods included from Language::AuxiliarLogger

#log

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 4

def options
  @options
end

#sessionObject (readonly)

Returns the value of attribute session.



4
5
6
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 4

def session
  @session
end

Instance Method Details

#backup(data, type:) ⇒ Object

Keep a copy of the requests/responses for future reference



19
20
21
22
23
24
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 19

def backup(data, type:)
  dry_run   = simulate? ? "_dry_run" : ""
  dir       = config.people.requests_folder
  file      = File.join(dir, "#{type}#{dry_run}.json")
  session.file_manager.save_json(data, file, :timestamp)
end

#configObject



10
11
12
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 10

def config
  session.config
end

#exit_error(msg) ⇒ Object



26
27
28
29
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 26

def exit_error(msg)
  logger.error(msg)
  exit(1)
end

#graphqlObject



6
7
8
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 6

def graphql
  @graphql ||= session.api(version: :graphql)
end

#simulate?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/eco/api/usecases/graphql/helpers/base.rb', line 14

def simulate?
  options.dig(:simulate)
end