I have two questions about query costs in Shopify GraphQL API:
- For the same GraphQL query with identical variables, will the requestedQueryCost always be consistent/identical?
- Is actualQueryCost always less than or equal to requestedQueryCost?
I’m trying to understand if I can reliably use requestedQueryCost for query planning and rate limiting in my application.
For the same GraphQL query with identical parameters (e.g., first:100
), I’ve tested across several of my test stores and found that the requestedQueryCost remains consistent, and actualQueryCost is always less than or equal to requestedQueryCost. Can I be confident that this behavior will be the same for all production stores as well?
for example:
GRAPHQL https://{{shopName}}/admin/api/2024-10/graphql.json
X-Shopify-Access-Token: {{token}}
{
products(first: 100) {
edges {
node {
title
variants(first: 5) {
edges {
node {
title
}
}
}
}
}
}
}
This query returns a requestedQueryCost of 56. Is this consistent across all Shopify stores?
I need to perform data synchronization, so I need to ensure that each request doesn’t exceed Shopify’s limits. If the requestedQueryCost is stable and actualQueryCost is guaranteed to be less than or equal to it, then I can be confident that my code will work correctly within the rate limits.