Question about consistency of requestedQueryCost and its relation to actualQueryCost in Shopify GraphQL API

I have two questions about query costs in Shopify GraphQL API:

  1. For the same GraphQL query with identical variables, will the requestedQueryCost always be consistent/identical?
  2. 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.

@Zwei_Black, your assumption is correct: RequestedQueryCost >= ActualQueryCost.

In your example, you will see 56 when your first 100 products all have at least 5 variants. Most of the time, it’s less than that, so you see a lower ActualQueryCost.