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
| Query | Operation | Description |
|---|---|---|
| ProductsQuery | products(...) | Return a list of products matching the given filters. Use for listing pages, search results, and category grids. |
| ProductQuery | product(...) | Return a single product. Use for product detail pages or server-side lookups by handle or ID. |
| ProductCountQuery | productCount(...) | 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:
| Argument | Type | Description |
|---|---|---|
handle | String | Filter by product handle (URL slug). Useful for single-product lookups on detail pages. |
yuiId | Int | Filter by the internal yStore numeric product ID. |
price | Float | Filter products by exact price. Typically used with range operators in advanced queries. |
specialPrice | Float | Filter by special/sale price. Returns only products that have a special price set. |
type | String | Filter by product type (e.g. simple, matrix, giftcard). |
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")
}