strawberry-graphql / strawberry-django

Strawberry GraphQL Django extension
https://strawberry.rocks/docs/django
MIT License
415 stars 120 forks source link

Adding total count in non-relay pagination #442

Closed stoicsleuth closed 5 months ago

stoicsleuth commented 11 months ago

Feature Request Type

Description

(Previously mentioned in https://github.com/strawberry-graphql/strawberry-graphql-django/issues/408)

Our project very extensively uses strawberry-graphql-django to expose nodes on our models. Earlier, we faced some issues related to pagination since the library only exposed totalCount of paginated results with Relay while we hadn’t built our project on top of Relay.

We had thus overridden some class methods with a previous version of strawberry-graphql-django, which again started breaking when we tried to upgrade to the latest one. Since overriding methods for pagination is not future-proof, I wanted to propose if we can accommodate 'totalCount' for pagination in the library without going through the Relay route.

I can try creating a PR for it if the idea aligns with the library’s roadmap. Let me know your thoughts.

Upvote & Fund

Fund with Polar

bellini666 commented 11 months ago

Hey @stoicsleuth ,

First of all:

Since overriding methods for pagination is not future-proof

We are not planning on breaking API for those in the future. The only reason for such breakeage would be if we had to do something which is incompatible with the current API

But having said that, sure, I think it is fair to have an alternative pagination structure which can expose extra data (such as totalCount) and is not reliant on relay.

PRs are totally welcomed! :)

bellini666 commented 5 months ago

This is mostly a duplicate of https://github.com/strawberry-graphql/strawberry-django/issues/408, so closing it for sanity :)