Sha256: 068e86ba164032af00039230cd8d87247b5bbd8090edc8d37b8404fe8b642ef0

Contents?: true

Size: 953 Bytes

Versions: 43

Compression:

Stored size: 953 Bytes

Contents

module Script
  module Layers
    module Infrastructure
      module ApiClients
        class ScriptServiceApiClient
          LOCAL_INSTANCE_URL = "https://script-service.myshopify.io"

          def initialize(ctx, api_key)
            instance_url = script_service_url
            @api = ShopifyCLI::API.new(
              ctx: ctx,
              url: "#{instance_url}/graphql",
              token: { "APP_KEY" => api_key }.compact.to_json,
              auth_header: "X-Shopify-Authenticated-Tokens"
            )
          end

          def query(query_name, variables: {})
            @api.query(query_name, variables: variables)
          end

          private

          def script_service_url
            if ::ShopifyCLI::Environment.use_spin?
              "https://script-service.#{::ShopifyCLI::Environment.spin_url}"
            else
              LOCAL_INSTANCE_URL
            end
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
shopify-cli-2.25.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.24.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.23.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.22.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.21.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.20.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.20.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.19.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.18.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.18.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.17.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.16.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.16.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.6 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.5 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.4 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.3 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.2 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.15.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb