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 |
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") {displayNamelabelpublished}}
This would give you a response similar to this --
{"data": {"product": {"displayName": "My product","label": "my-product","published": true}}}
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) {displayNamelabelpublished}}
This will return the unpublished product:
{"data": {"product": {"displayName": "My Unpublished Product","label": "my-unpublished-product","published": false}}}