GraphQL Pagination “total”
When using the GraphQL dataprovider with useTable & pagination where does the “total” number of data get populated?
I see where “data?total” is referenced with pageSize to get the number of pages. What I don’t see is how/where “total” gets resolved. Any insight appreciated! Thank you.
I see where “data?total” is referenced with pageSize to get the number of pages. What I don’t see is how/where “total” gets resolved. Any insight appreciated! Thank you.
3 Replies
Hi @peterson79.. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The "total" number of data when using the GraphQL data provider with
useTable
and pagination in Refine is determined by the total
value returned from the data provider. This value is independent of the pagination mode.
If you're facing issues with the total count, it might be because your API is not returning a total value. In such cases, you can swizzle your data provider and customize the getList
method to ensure the total value is being sent correctly.
Here's an example of a GraphQL response structure where the count
is returned at the same level as data
:
In this example, total: response[operation].count
should work if you don't swizzle. However, the exact implementation might depend on your specific data provider and backend setup. If you're still facing issues, you might need to debug your code after swizzling.
For more information on how to use the GraphQL data provider with Refine, you can refer to the official documentation (https://refine.dev/docs/packages/documentation/data-providers/graphql).
Sources:
- Discord support thread: Clientside Pagination Total Count (https://discord.com/channels/837692625737613362/1090367190219370526)
- Refine vs React-Admin Which is Better for Your Project? (https://refine.dev/blog/refine-vs-react-admin/)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@884278709840916531> kapa.ai is still learning and improving, please let us know how it did by reacting below
vicious-gold•14mo ago
Hello @peterson79. you can check this line: https://github.com/refinedev/refine/blob/master/packages/graphql/src/dataProvider/index.ts#L44
GitHub
refine/packages/graphql/src/dataProvider/index.ts at master · refin...
A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibilty. - refinedev/refine