Graphql query products filtered by quantity

How can i filter products based on quantity(low stock products < 10 not sold out) using admin graphql also i want total products with quantity less than 10.

Hey! @Swiftbee ,

To filter products with inventory quantity less than 10 and not sold out using Shopify Admin GraphQL API, you need to query productVariants and filter based on inventoryQuantity. Here’s an example:

{
  productVariants(first: 100, query: "inventory_quantity:<10 AND inventory_quantity:>0") {
    edges {
      node {
        id
        title
        inventoryQuantity
        product {
          title
          id
        }
      }
    }
  }
}

This query fetches variants with quantity between 1 and 9. To get the total count, you can use productVariants with query: and access pageInfo or keep paginating while counting manually, as GraphQL doesn’t return total count directly.