feat: base hasNextPage in connectionPlugin upon gt not gte (#458)
closes #392 BREAKING CHANGE: Remember that internally Nexus Schema over-fetches by 1 but hides this internally. It used to be that `SomeEdge.hasNextPage` would be `true` _if_ the number of returned nodes was greater-than OR equal-to the `first` arg value given in the query. Now when Nexus Schema treats the `equal-to` case as `SomeEdge.hasNextPage` being `false`. Co-authored-by: Eyal Wiener <eyalwiener@gmail.com>
This commit is contained in:
parent
5b900b156a
commit
122b0e17b0
|
@ -840,7 +840,7 @@ function defaultHasNextPage(nodes: any[], args: PaginationArgs) {
|
|||
// If we're paginating forward, and we don't have an "after", we'll assume that we don't have
|
||||
// a previous page, otherwise we will assume we have one, unless the after cursor === "0".
|
||||
if (typeof args.first === "number") {
|
||||
return nodes.length >= args.first;
|
||||
return nodes.length > args.first;
|
||||
}
|
||||
// If we're paginating backward, and there are as many results as we asked for, then we'll assume
|
||||
// that we have a previous page
|
||||
|
|
|
@ -171,7 +171,7 @@ Object {
|
|||
],
|
||||
"pageInfo": Object {
|
||||
"endCursor": "Y3Vyc29yOjk=",
|
||||
"hasNextPage": true,
|
||||
"hasNextPage": false,
|
||||
"hasPreviousPage": false,
|
||||
"startCursor": "Y3Vyc29yOjA=",
|
||||
},
|
||||
|
|
|
@ -252,7 +252,7 @@ describe("connectionPlugin", () => {
|
|||
});
|
||||
expect(lastNodes.data?.users.pageInfo).toEqual({
|
||||
endCursor: "Y3Vyc29yOjk=",
|
||||
hasNextPage: true,
|
||||
hasNextPage: false,
|
||||
hasPreviousPage: false,
|
||||
startCursor: "Y3Vyc29yOjA=",
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue