Querying single products

You can fetch a single product with the product query --

product(id: ID, label: String, latest: Boolean): Product

This query allows you to fetch a single product from either its id or label .

Parameter

Description

id

the unique identifier for this product

label

the unique label identifying this product (ignored if id is provided)

latest

indicates we want the latest available version

You must provide either id or label. If you provide both, label is ignored. For example, to search for a product named my-product you could send the following query:

{
product(label:"my-product") {
displayName
label
published
}
}

This would give you a response similar to this --

{
"data": {
"product": {
"displayName": "My product",
"label": "my-product",
"published": true
}
}
}

Dealing with Unpublished Products

If you created a product on Plan Builder but haven't published it yet, the search above would result in an error:

{
"errors": [
{
"message": "The requested resource is not found",
"path": [
"product"
],
"extensions": {
"type": "NotFound"
}
}
],
"data": {
"product": null
}
}

That's because by default the query only looks for published products. If you need to fetch information on an still-unpublished product, you can use the latest parameter --

{
product(label:"my-unpublished-product", latest: true) {
displayName
label
published
}
}

This will return the unpublished product:

{
"data": {
"product": {
"displayName": "My Unpublished Product",
"label": "my-unpublished-product",
"published": false
}
}
}

‚Äč