Class: Ecoportal::API::Common::GraphQL::Client

Inherits:
Graphlient::Client
  • Object
show all
Includes:
AuthService
Defined in:
lib/ecoportal/api/common/graphql/client.rb

Constant Summary collapse

READ_TIMEOUT =
90
WRITE_TIMEOUT =
90

Constants included from AuthService

AuthService::DEFAULT_SERVER, AuthService::TOKEN_AUTORENEW

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AuthService::InstanceMethods

#session_token, #session_token_renewed

Constructor Details

#initialize(email: nil, pass: nil, org_id: self.org_id, host: server, schema_path: host, no_schema: false) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ecoportal/api/common/graphql/client.rb', line 14

def initialize(
  email:       nil,
  pass:        nil,
  org_id:      self.org_id,
  host:        server,
  schema_path: host,
  no_schema:   false
)
  @org_id      = org_id
  @host        = host
  @no_schema   = no_schema
  @user_email  = email
  @user_pass   = pass

  puts "Configuring GraphQL Client onto '#{url}'"
  super(url,
    headers:      {
      'Authorization' => "Bearer #{session_token(host: host)}"
    },
    http_options: {
      read_timeout:  READ_TIMEOUT,
      write_timeout: WRITE_TIMEOUT
    }.tap do |options|
      options.merge!(schema_path: schema_path) unless @no_schema
    end
  )
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



7
8
9
# File 'lib/ecoportal/api/common/graphql/client.rb', line 7

def host
  @host
end

Instance Method Details

#new(org_id: self.org_id, host: self.host, schema_path: host, no_schema: @no_schema) ⇒ Object



42
43
44
# File 'lib/ecoportal/api/common/graphql/client.rb', line 42

def new(org_id: self.org_id, host: self.host, schema_path: host, no_schema: @no_schema)
  self.class.new(org_id: org_id, host: host, schema_path: schema_path, no_schema: no_schema)
end

#org_idObject



46
47
48
# File 'lib/ecoportal/api/common/graphql/client.rb', line 46

def org_id
  @org_id || fetch_env_required("ORGANIZATION_ID")
end