Hi Benjamin,
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
queryparameter in Shopify’s GraphQL API uses a search syntax similar to the one used in the Shopify admin. It’s possible that theinventory_policyfield 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 withinventoryPolicyset toCONTINUE. -
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.
Hope this helps!