Skip to main content
Version: 1.0.0

ProductQuery

Description

Retrieves a single product based on specified criteria. This query is useful when you need to fetch detailed information about a specific product.

Endpoint

query product($handle: [QueryArgument], $yuiId: [QueryArgument], $id: [QueryArgument]) {
product(handle: $handle, yuiId: $yuiId, id: $id) {
# Return fields
}
}

Arguments

ArgumentTypeRequiredDescription
handle[QueryArgument]NoNarrows the query results based on the handle on the product.
yuiId[QueryArgument]NoNarrows the query results based on the YUI ID on the product.
price[QueryArgument]NoNarrows the query results based on the price on the product.
price_incl_tax[QueryArgument]NoNarrows the query results based on the price including tax on the product.
price_excl_tax[QueryArgument]NoNarrows the query results based on the price excluding tax on the product.
specialPrice[QueryArgument]NoNarrows the query results based on the special price on the product.
special_price_incl_tax[QueryArgument]NoNarrows the query results based on the special price including tax on the product.
special_price_excl_tax[QueryArgument]NoNarrows the query results based on the special price excluding tax on the product.
type[String]NoNarrows the query results based on the product type the products belong to per the product type's handles.

Common Element Arguments

In addition to the specific arguments above, this query also supports common element arguments:

ArgumentTypeRequiredDescription
id[QueryArgument]NoNarrows the query results based on the element's ID.
uid[String]NoNarrows the query results based on the element's UID.
status[String]NoNarrows the query results based on the element's status.
title[String]NoNarrows the query results based on the element's title.
slug[String]NoNarrows the query results based on the element's slug.
siteIdIntNoDetermines which site to fetch results from.

Return Values

The query returns a single Product object with the following fields:

FieldTypeDescription
idIDThe unique identifier for the product.
titleStringThe title of the product.
handleStringThe handle of the product.
yuiIdStringThe YUI ID of the product.
priceFloatThe base price of the product.
price_incl_taxFloatThe price including tax of the product.
price_excl_taxFloatThe price excluding tax of the product.
specialPriceFloatThe special price of the product, if applicable.
special_price_incl_taxFloatThe special price including tax of the product, if applicable.
special_price_excl_taxFloatThe special price excluding tax of the product, if applicable.
typeStringThe type of the product.
urlStringThe URL of the product.
......Additional fields depending on the product type.

Usage Example

query {
product(handle: "sample-product-1") {
id
title
handle
price
price_incl_tax
url
}
}

Example Response

{
"data": {
"product": {
"id": "123",
"title": "Sample Product 1",
"handle": "sample-product-1",
"price": 19.99,
"price_incl_tax": 23.99,
"url": "/products/sample-product-1"
}
}
}

Notes

  • This query returns a single product. If multiple products match the criteria, only the first one will be returned.
  • It's recommended to use a unique identifier like id, handle, or yuiId to ensure you get the specific product you're looking for.
  • If no product matches the criteria, the query will return null.
  • The QueryArgument type allows for various comparison operators, but when querying for a single product, it's usually best to use exact matching.
  • The available fields in the response depend on the product type and may include custom fields defined in your product types.