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.14.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.13.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.12.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.11.2 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.11.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.11.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.10.2 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.10.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.10.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.9.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.8.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.7.4 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.7.3 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.7.2 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.7.1 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.7.0 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.6.6 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.6.5 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.6.4 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb
shopify-cli-2.6.3 lib/project_types/script/layers/infrastructure/api_clients/script_service_api_client.rb