GraphQL Admin API for filter products based on variant's inventoryPolicy

GraphQL Admin API for filter products based on variant's inventoryPolicy

pa1997
Shopify Partner
2 0 2

 I am using GraphQL Admin API for my app and I need to write a Grapql query to fetch products which have at least one product variant's inventoryPolicy as "CONTINUE". I use the below GraphQL query for it and it doesn't work. As a workaround, I can do this filtration on the client side but it is hard to maintain pagination so is there any way to do it at the query level?  Below query return all the CONTINUE  and DENY  inventoryPolicyquery

getProducts {
products(
first: 4
query: "status:active AND variants.inventory_policy:CONTINUE "
) {
pageInfo {
hasNextPage
hasPreviousPage
endCursor
startCursor
}
edges {
node {
id
title
handle
featuredImage {
transformedSrc
}
status
vendor
variants(first: 20) {
edges {
node {
id
title
availableForSale
inventoryQuantity
inventoryPolicy
}
}
}
}
}
}
}
Reply 1 (1)

Himanshu7
Shopify Partner
17 0 0
Shopify doesn't provide the data based on the "inventory_policy: Continue or inventoryPolicy: Continue". It returns the whole variants data of the products. We can create an array based on the inventoryPolicy condition in php after fetching all the graphql data.

You need to get all the data and then apply filter from the result.
HP