T
TanStack•11mo ago
adverse-sapphire

What is the basic response model required by useInfiniteQuery

I am using KUBB with pluginTanstackQuery to generate Tanstack Query hooks from an OAS3 spec (Swagger). I have limited access to how generated queries are created e.g. no access to define getNextPageParam from UseInfiniteQueryOptions where I could do calculations of "pages" if thats not part of the response. So what would be the "default" way for a response to be constructed to work out of the box with useInfiniteQuery so to speak? The current response model looks like this: {totalCount: number, offset: number, limit: number, hasMore: boolean, data: array}
3 Replies
conscious-sapphire
conscious-sapphire•11mo ago
You would have to ask the people behind KUBB. React Query itself has no limitations in that regard.
adverse-sapphire
adverse-sapphireOP•11mo ago
You are absolutely right and I did, but did not get an answer (yet anyway). 🙂 I simply haven't understood the documentation for getNextPageParam. What decides what parameter that is? In some examples it is called nextId, in some nextCursor. I kind of get that in my example where the backend does not have a notion of a page only a pointer (offset) and a pagesize (limit), I would have to do the calculation in the function somehow but since it is generated I do not have access to it.
conscious-sapphire
conscious-sapphire•11mo ago
yeah might be that kubb makes some assumptions around that - react-query itself does not in "raw" react-query, you would just implement the function and return whatever you want. if it's paginated and you have no cursor, you could just access pages.length and add + 1 to it.
In some examples it is called nextId, in some nextCursor.
this is usually irrelevant

Did you find this page helpful?