A user is experiencing an issue where the inventory_policy parameter is being ignored in a GraphQL productVariants query.
Problem Details:
The query successfully filters by inventory_quantity (≤0)
However, it returns variants with both CONTINUE and DENY inventory policies, despite specifying inventory_policy:CONTINUE in the query
Multiple variations have been tested: different capitalizations (CONTINUE, continue, Continue) and parameter naming (inventoryPolicy vs inventory_policy)
Suggested Troubleshooting:
The inventory_policy field may not support exact matching through the query parameter syntax
Alternative approaches:
Use Shopify’s GraphiQL app for real-time testing and auto-suggestions to identify issues
Fetch variants based on inventory_quantity only, then filter results client-side or server-side for CONTINUE policy
Status: The issue remains unresolved, with the discussion exploring workarounds since direct filtering appears not to work as expected.
Summarized with AI on November 17.
AI used: claude-sonnet-4-5-20250929.
I am running a query, looking for all variants that have 0 or less in stock and have CONTINUE as its inventory policy.
The query is tested and works in all ways but the ignored query.
It does filter by inventory_quantity correctly, but ignores the second query, returning variants both with inventory_policy CONTINUE, and DENY.
I’ve tried using CONTINUE, continue, or Continue.
I’ve tried setting the parameter as inventoryPolicy instead of inventory_policy.
I’ve tried removing the quantity parameter, only querying “inventory_policy:CONTINUE”.
The query does return the inventoryPolicy, and its content is either “DENY” or “CONTINUE”
{
productVariants(
first: 100
query: "inventory_policy:CONTINUE AND inventory_quantity:<=0"
) {
nodes {
inventoryPolicy
product {
title
}
title
}
}
}
Your GraphQL query seems correct in its structure. The productVariants query with the query parameter is the right way to filter product variants based on certain conditions. However, there are a few things to consider:
Exact Match: The query parameter in Shopify’s GraphQL API uses a search syntax similar to the one used in the Shopify admin. It’s possible that the inventory_policy field doesn’t support exact matching in the way you’re attempting.
Alternative Approach: If the direct query doesn’t work as expected, you might need to fetch the variants based on one condition (e.g., inventory_quantity:<=0) and then filter the results on your server or client side to get only those with inventoryPolicy set to CONTINUE.
Testing: Use tools like Shopify’s GraphiQL app to test your queries. This tool provides real-time feedback and auto-suggestions, which can help identify issues.