Skip to content
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

Total count when paginating #365

Closed
ohuu opened this issue Nov 10, 2020 · 4 comments
Closed

Total count when paginating #365

ohuu opened this issue Nov 10, 2020 · 4 comments

Comments

@ohuu
Copy link

ohuu commented Nov 10, 2020

I may be misunderstanding how pagination works but shouldn't there be a totalCount when requesting products so I know how many buttons to render for pagination?

@jacobarriola
Copy link
Contributor

@PaperPlaneSoftware you should check this comment for the reasoning of omitting totalCount in core WPGraphQL: wp-graphql/wp-graphql#261 (comment)

@ohuu
Copy link
Author

ohuu commented Nov 10, 2020

@jacobarriola thanks for the quick reply. I read this article forward and backward pagination with wpgraphql by @jasonbahl and while I don't completely agree with it (I think there are times when knowing the total number of posts is useful, especially if there are only a few 10's of posts) I can understand why the decision was made.

I think it would be better if the decision for page based vs cursor based pagination was left to the developer using WPGraphQL. Is there a recommended way to do page based pagination? I guess I would have to extend the resolver somehow? Any pointers would be very much appreciated.

Cheers

@jacobarriola
Copy link
Contributor

jacobarriola commented Nov 10, 2020

Perhaps this extension can be a good guide: https://github.com/darylldoyle/wp-graphql-offset-pagination

There's also this one that exposes the totalCount field to the schema: https://github.com/builtbycactus/total-counts-for-wp-graphql

@ohuu
Copy link
Author

ohuu commented Nov 10, 2020

That's perfect! I guess I did have the choice all along just didn't know about that plugin. Thanks so much.

@ohuu ohuu closed this as completed Nov 10, 2020
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