Skip to content

Wrong algorithm for pageInfo.hasPreviousPage and pageInfo.hasNextPage? #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hybrid-Force opened this issue May 27, 2020 · 2 comments
Closed

Comments

@Hybrid-Force
Copy link
Contributor

Thanks for the amazing library, first of all!

Please correct me if I am wrong, it seems that the algorithm for pageInfo.hasPreviousPage and pageInfo.hasNextPage fields are not following with the cursor connections spec.

pageInfo.hasPreviousPage = (!!args.last || !args.first) && (skip > 0 || !!args.after);
pageInfo.hasNextPage = (!!args.first || !args.last) && hasExtraRecords;

With current implementation, in forward pagination situation with first/after, pageInfo.hasPreviousPage is always set to false. And pageInfo.hasNextPage always false in backward pagination. In forward pagination, pageInfo.hasNextPage is only working with first and last both set, which is discouraged.

I am wondering if this deviation from the spec is intentional or is it a potential bug?

@nodkz
Copy link
Member

nodkz commented May 29, 2020

It looks like a bug. Can you provide test case or send a pull request?

@Hybrid-Force
Copy link
Contributor Author

It looks like a bug. Can you provide test case or send a pull request?

Sure, I will try put together a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants