evident-indigo
evident-indigo6mo ago

Hi Everyone.

Hi Everyone. I am building some CRUD pages in our product and found Refine to be a great fit for our case. With that, I am having an issue - I am using @refinedev/graphql provider, and can't figure out how to make pagination work. My list query returns an array of entities, and I don't see a way to add count variable. it is used here in provider
return {
data: response[operation],
total: response[operation].count,
};
return {
data: response[operation],
total: response[operation].count,
};
my query is defined as entities(...): [Entity!]! how can I add count here? Any advice is deeply appreciated.
4 Replies
like-gold
like-gold6mo ago
Hello @karabur the solution depends on your GraphQL API, apis has different ways to provide total count. If your API is using relay spec, it's under pageInfo for example.
rising-crimson
rising-crimson6mo ago
Hi @Batu , The issue here is that the @refinedev/graphql provider expects specific data format in response - to have count on the response but also uses the response itself as data. It is not about what GraphQL API I use but about what that provider is expecting and what the data shape should look like. if response[operation] is an array, it is not possible to add count there, if it is not an array, then it is unclear what else it should be. I can't find any example demonstrating pagination with @refinedev/graphql provider. Graphql example on a Refine site using old approach.
harsh-harlequin
harsh-harlequin3mo ago
I also just ran into this conundrum. It doesn't make sense given that lists in graphQL cannot contain properties. I cannot see how anyone using this default GraphQL data provider could have working pagination.
harsh-harlequin
harsh-harlequin3mo ago
I created an issue for it here: https://github.com/refinedev/refine/issues/5942
GitHub
[BUG] Default GraphQL DataProvider GetListResponse from 'count' pro...
Describe the bug The default GraphQL providers getList function return the following GetListResponse shaped object: refine/packages/graphql/src/dataProvider/index.ts Lines 39 to 42 in 3046f96 retur...