pothos
pothos copied to clipboard
Backward pagination with resolveOffsetConnection not working with the Relay pagination plugin
We use resolveOffsetConnection with the relay pagination plugin.
Seems that hasNextPage is not properly updated when you paginate in the opposite direction.
This query for forward pagination works:
products(first: 10, after: "T2Zmc2V0Q29ubmVjdGlvbjoxOQ==") {
edges {
cursor
node {
id
title
}
}
pageInfo {
endCursor
startCursor
hasNextPage
hasPreviousPage
}
totalCount
}
result:
"pageInfo": {
"endCursor": "T2Zmc2V0Q29ubmVjdGlvbjoyNA==",
"startCursor": "T2Zmc2V0Q29ubmVjdGlvbjoyMA==",
"hasNextPage": false,
"hasPreviousPage": true
},
"totalCount": 25
This query for backward pagination doesn't work:
query products {
storeProducts(last: 10, before: "T2Zmc2V0Q29ubmVjdGlvbjoyNA==") {
edges {
cursor
node {
id
title
}
}
pageInfo {
endCursor
startCursor
hasNextPage
hasPreviousPage
}
totalCount
}
}
result:
"pageInfo": {
"endCursor": "T2Zmc2V0Q29ubmVjdGlvbjoyMw==",
"startCursor": "T2Zmc2V0Q29ubmVjdGlvbjoxNA==",
"hasNextPage": false,
"hasPreviousPage": true
},
"totalCount": 25
hasNextPage should be true?
jest released a fix, let me know if you are still having issues after upgrading
Lighting fast fix and works great! 🙏👍