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:
Jason Kuhrt 2020-07-01 16:16:09 -04:00 committed by GitHub
parent 5b900b156a
commit 122b0e17b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -171,7 +171,7 @@ Object {
],
"pageInfo": Object {
"endCursor": "Y3Vyc29yOjk=",
"hasNextPage": true,
"hasNextPage": false,
"hasPreviousPage": false,
"startCursor": "Y3Vyc29yOjA=",
},

View File

@ -252,7 +252,7 @@ describe("connectionPlugin", () => {
});
expect(lastNodes.data?.users.pageInfo).toEqual({
endCursor: "Y3Vyc29yOjk=",
hasNextPage: true,
hasNextPage: false,
hasPreviousPage: false,
startCursor: "Y3Vyc29yOjA=",
});