Pagination
Whenever two objects have a one-to-many relationship, the respective field will be paginated using cursor-based, forward pagination.
As pagination is not yet fully implemented, all paginated fields will currently return all results. However, to avoid breaking changes once pagination will be enabled, the respective pattern is already prepared and enforced.
Nodes and Edges
Objects that share a relationship within our API are referred to as nodes and their connections as edges. To enable pagination, a field representing a one-to-many relationship contains a single edges
object, which in turn is a list of nodes. Each such node
object represents a single related item.
According to this structure, you could query the title of all 8.SET Compose product sets for a product with the SKU 123456-7890
in your catalogue by using the follwing query:
The responding result will reflect the same structure:
Slicing
An optional parameter first
can be used to limit the number of items returned in a result list.
The following query for example, would allow you to return only a single 8.SET Compose product set for a product with the SKU 123456-7890
in your catalogue:
You can pass an arbitrary positive integer to the first
argument. Bear in mind though, that the result will always be the same shape, even if you request a single item. So the above query would result in:
Cursor-based pagination
As mentioned above, pagination is not yet fully implemented. The following section is thus just a preview of how to use the cursor-based, forward pagination once it will be implemented.
The after
parameter can be used to traverse through a paginated result. It expects a cursor value which can be obtained from the previous response.
Using a combination of slicing and cursor-based pagination for example, you could iterate through a list of 8.SET Compose product sets one by one:
This would result in the following response:
Now using the cursor from this response we can query the next product set:
Which would in turn respond with the following result:
Following this pattern we could continue traversing through the list of all relevant product sets. Additionally, this approach is very flexible and even enables changing slice sizes between consecutive queries as the used cursor is always based on the previous result.
Last updated