I’m getting some unexpected behavior when paginating productVariants sorted by FULL_TITLE but not when sorting by, say, SKU. When getting to the last page of FULL_TITLE results I’m seeing this response where both end and start cursors are the same. And when I use that cursor to try to get the next page, there are no product variants returned. However, when I sort by SKU I get to the last page and hasNextPage is false as expected. Not sure if the sorting is masking some other issue.
Here is the query and inputs:
query ProductVariantsSearch($limit: Int!, $query: String, $cursor: String) {
productVariants(
first: $limit
query: $query
after: $cursor
sortKey: FULL_TITLE
) {
edges {
node {
product {
title
vendor
}
sku
title
}
}
pageInfo {
hasNextPage
endCursor
hasPreviousPage
startCursor
}
}
}
Inputs
{
"limit": 3,
"query": "",
"cursor": "eyJsYXN0X2lkIjo0MzkxNTAzMDUyODE2MiwibGFzdF92YWx1ZSI6WyJhY29ybiBzcXVhc2giLDgxMzUwNTM5Njc1MjIsNV19"
}
Returns the last item and this pageInfo:
"pageInfo": {
"hasNextPage": true,
"endCursor": "eyJsYXN0X2lkIjo0MzkxNTAyNDcyODIyNiwibGFzdF92YWx1ZSI6WyJhbGknaSBrdWxhIGxhdmVuZGVyIGRhcmsgbWlsayBjaG9jb2xhdGUgYmFyIiw4MTM1MDQ4NDk1MjY2LDFdfQ==",
"hasPreviousPage": true,
"startCursor": "eyJsYXN0X2lkIjo0MzkxNTAyNDcyODIyNiwibGFzdF92YWx1ZSI6WyJhbGknaSBrdWxhIGxhdmVuZGVyIGRhcmsgbWlsayBjaG9jb2xhdGUgYmFyIiw4MTM1MDQ4NDk1MjY2LDFdfQ=="
}
Then try to get the next page with
{
"limit": 3,
"query": "",
"cursor": "eyJsYXN0X2lkIjo0MzkxNTAyNDcyODIyNiwibGFzdF92YWx1ZSI6WyJhbGknaSBrdWxhIGxhdmVuZGVyIGRhcmsgbWlsayBjaG9jb2xhdGUgYmFyIiw4MTM1MDQ4NDk1MjY2LDFdfQ=="
}
And no product variants are returned.
But it works when sorting by SKU (maybe a red herring).