Class: Istox::GraphqlClient

Inherits:
Object
  • Object
show all
Defined in:
lib/istox/helpers/graphql_client.rb

Class Method Summary collapse

Class Method Details

.add_host(host_type, url) ⇒ Object



7
8
9
10
11
12
# File 'lib/istox/helpers/graphql_client.rb', line 7

def add_host(host_type, url)
    unless defined?(@@hosts)
       @@hosts = {}
    end
    init_host(host_type, url)
end

.parse(host_type, query) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/istox/helpers/graphql_client.rb', line 22

def parse(host_type, query) 
  client = @@hosts[host_type]

  raise "Please make sure you have initialised graphql cient for host #{host_type}" if !client

  return client.parse(query)
end

.query(host_type, query, variables = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/istox/helpers/graphql_client.rb', line 14

def query(host_type, query, variables = {})
  client = @@hosts[host_type]

  raise "Please make sure you have initialised graphql cient for host #{host_type}" if !client

  result = client.query(query, variables: variables)
end