Welcome to mirror list, hosted at ThFree Co, Russian Federation.

graphql.rb « clients « bulk_imports « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 89698cb53ef45731275128ce2d474e586600f6bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module BulkImports
  module Clients
    class Graphql
      attr_reader :client

      delegate :query, :parse, :execute, to: :client

      def initialize(url: Gitlab::COM_URL, token: nil)
        @url = Gitlab::Utils.append_path(url, '/api/graphql')
        @token = token
        @client = Graphlient::Client.new(
          @url,
          request_headers
        )
      end

      def request_headers
        return {} unless @token

        {
          headers: {
            'Content-Type' => 'application/json',
            'Authorization' => "Bearer #{@token}"
          }
        }
      end
    end
  end
end