Listing products

To list products, you can use the products query --

products(first: Int!, after: String, orderBy: ProductOrderBy): ProductConnection

This query returns a list of product nodes with pagination. Note that this query will return all products, of all users on Plan Builder, not only yours.

Fetching a list of products

To get the first 10 products, you can send this query to the GraphQL endpoint:

{
products(first:10) {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
label
}
}
}
}

This would return the label field of the first 10 products found. The response would look like this (edited for brevity) --

{
"data": {
"products": {
"pageInfo": {
"endCursor": "ech72ybgcmh3m8h25gh66xbjedqq48hu48r30c1k6hhq8vb4chm7223375r6ccb8e1gqaxhmcgwpwdv3enu6et3eenr7et9te9jkjxvh61u64dtp60h2r8kfe9j6awh279xquz8",
"hasNextPage": true
},
"edges": [
{
"node": {
"label": "my-product-1"
}
},
{
"node": {
"label": "my-product-2"
}
},
(...)
{
"node": {
"label": "my-product-10"
}
}
]
}
}
}

You can see that hasNextPage is true, so we know there are more results available. We can get to the next 10 by using the endCursor in the next query --

{
products(first:10, after:"ch72ybgcmh3m8h25gh66xbjedqq48hu48r30c1k6hhq8vb4chm7223375r6ccb8e1gqaxhmcgwpwdv3enu6et3eenr7et9te9jkjxvh61u64dtp60h2r8kfe9j6awh279xquz8") {
pageInfo {
endCursor
hasNextPage
}
edges {
node {
label
}
}
}
}

This will give us the next "page" of results.

{
"data": {
"products": {
"pageInfo": {
"endCursor": "m7223375r6ccb8e1gqaxhmcgwpwdv3enu6et3eenr7et9te9jkjxvh61u64dtp60h2r8kfe9j6awh279xquzech72ybgcmh3m8h25gh66xbjedqq48hu48r30c1k6hhq8vb4ch8",
"hasNextPage": false
},
"edges": [
{
"node": {
"label": "my-product-11"
}
},
{
"node": {
"label": "my-product-12"
}
}
]
}
}
}

The first result in this query is the very next product after the results of that previous call. Also note how this time we only got two results, instead of the requested 10. This can happen when there are less available results than the requested number. Also note that hasNextPage is now false, meaning there are no more results. That tells you that you are at the end of the "pages." For more details, see Pagination.