Sha256: 74ce5a5a7ebd1e4868a1a24dbf8099828c743b422ea67ce543a4b071bdd0f0e9

Contents?: true

Size: 1.49 KB

Versions: 14

Compression:

Stored size: 1.49 KB

Contents

require 'graphlient'
module Ecoportal
  module API
    module Common
      module GraphQL
        class Client < ::Graphlient::Client
          attr_accessor :org_id, :host

          include Ecoportal::API::Common::GraphQL::AuthService

          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}"
              },
              http_options: {
                read_timeout: 20,
                write_timeout: 30
              }.tap do |options|
                options.merge!(schema_path: schema_path) unless @no_schema
              end
            )
          end

          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

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

          private

          def url
            "#{Ecoportal::API::Common::GraphQL::HttpClient.base_url(host)}/api/#{org_id}/graphql"
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ecoportal-api-graphql-0.3.3 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.3.1 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.2.3 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.2.2 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.2.1 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.11 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.10 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.9 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.8 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.7 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.6 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.5 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.4 lib/ecoportal/api/common/graphql/client.rb
ecoportal-api-graphql-0.1.3 lib/ecoportal/api/common/graphql/client.rb