View Source ShopQL (shopql v0.1.0)

Client library for the Shopify GraphQL Admin API.

Link to this section Summary

Functions

Submits a query to the Shopify Admin GraphQL API. Returns {:ok, body} or {:error, body}.

Link to this section Functions

Link to this function

query(query, variables \\ %{}, opts)

View Source

Submits a query to the Shopify Admin GraphQL API. Returns {:ok, body} or {:error, body}.

options

Options

  • :access_token - Required. Shopify access token.

  • :api_version - Required. Shopify API version, like 2022-07.

  • :max_attempts - Maximum number of attempts to make. You should only increase this value when making an idempotent request. The default value is 1.

  • :max_attempts_rate_limit - Maximum number of attempts to make. This only applies when Shopify returns an error indicating that the rate limit has been exceeded. The default value is 3.

  • :min_retry_delay - Delay in ms between failed attempts. The delay will be doubled after each subsequent retry. For example, if set to 500 the first delay will be 500ms, the second 1000ms, and the third 2000ms. This doesn't apply when a rate limit error occurs. The default value is 500.

  • :shop_name - Required. Your Shopify domain is <shop_name>.myshopify.com.

retries-after-error

Retries after error

The retry logic depends upon the type of error. A warnings will be logged whenever a request is retried.

  • Connection errors like a 5xx HTTP response or timeout - Request will be retried up to :max_attempts times. For this type of error we don't know whether or not Shopify ran the query. Therefore, only increase :max_attempts if you are running an idempotent query. The :min_retry_delay setting applies in this case.
  • Rate limit exceeded error - Failed request will be retried up to :max_attempts_rate_limit times. For this type of error we know that Shopify didn't run the query so it is safe to retry even if your query is not idempotent. Will delay between requests for enough time for Shopify's cost points to be fully replenished.
  • GraphQL error ("errors" key in response) - Request will never be retried because this type of error generally means that your request is invalid and if we retry we'll just get the same error again.