View Source ShopQL (shopql v0.2.2)
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}
.
Like query/3
, except raises ShopQL.Error
if an error occurs.
Link to this section Functions
Submits a query to the Shopify Admin GraphQL API.
Returns {:ok, body}
or {:error, body}
.
options
Options
:access_token
(String.t/0
) - Required. Shopify access token.:api_version
(String.t/0
) - Required. Shopify API version, like2022-07
.:max_attempts
(pos_integer/0
) - Maximum number of attempts to make. You should only increase this value when making an idempotent request. The default value is1
.:max_attempts_rate_limit
(pos_integer/0
) - 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 is3
.:min_retry_delay
(pos_integer/0
) - Delay in ms between failed attempts. The delay will be doubled after each subsequent retry. For example, if set to500
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 is500
.:shop_name
(String.t/0
) - 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.
Like query/3
, except raises ShopQL.Error
if an error occurs.