Skip to main content
Version: 2.0.0

Product Queries

yStore registers three product query operations in src/gql/queries/Product.php. All three share the same argument schema defined in src/gql/arguments/elements/Product.php, so any filter you can apply to products can also be applied to productCount.

Available queries

QueryOperationDescription
ProductsQueryproducts(...)Return a list of products matching the given filters. Use for listing pages, search results, and category grids.
ProductQueryproduct(...)Return a single product. Use for product detail pages or server-side lookups by handle or ID.
ProductCountQueryproductCount(...)Return the total count of products matching the given filters. Use alongside products for pagination.

yStore product arguments

In addition to the standard Craft element arguments (such as id, slug, status, site, search, limit, offset, orderBy), yStore adds the following product-specific arguments:

ArgumentTypeDescription
handleStringFilter by product handle (URL slug). Useful for single-product lookups on detail pages.
yuiIdIntFilter by the internal yStore numeric product ID.
priceFloatFilter products by exact price. Typically used with range operators in advanced queries.
specialPriceFloatFilter by special/sale price. Returns only products that have a special price set.
typeStringFilter by product type (e.g. simple, matrix, giftcard).
tip

When building a paginated product grid, pass identical arguments to both products and productCount. Keeping the filters in sync avoids page-count mismatches as customers apply filters.

Access control

Product query access is gated by GqlHelper::canQueryProducts(). Ensure your GraphQL schema grants the appropriate token or schema scope before exposing product queries to anonymous users.

Example

query ProductListing($type: String, $limit: Int, $offset: Int) {
products(type: $type, limit: $limit, offset: $offset, status: "live") {
id
title
handle: slug
price
specialPrice
}
productCount(type: $type, status: "live")
}