Note: the following examples are based on the API Stream integration concept - if you are not yet familiar with it check an overview of the Query types to understand the approach.
first
parameter put on limit how many categories are fetched in one result
example response:
Since we received information that the next page exists data.categoryStream.pageInfo.hasNextPage=true
we should request the next resource. The query is very similar to the previous one except we are passing the appropriate cursor
with the request:
after
parameter represents the appropriate cursor that identifies a last-fetched resource. Available as either cursor
field of the node or the endCursor
of PageInfo
object.
example response:
we do know that there is no next page, therefore, there is nothing to fetch at the very moment. We can retry the next request(for the retrieved cursor) with i.e., an increased interval not to waste resources.
Alternatively in some systems, we will want only to fetch the identifier of the resource using some sort of queueing system in order to distribute the consumption processes. In that case, we can just fetch our resource ID (code in the case of categories) and the PageInfo
object:
and fetch it in the separate consuming process via a single resource query:
The rest of the process looks the same for the paginating over the stream.
Though given above content provides an example of handling categories you can use the same approach for every other resource available via streams like products, multimedia, and attributes.