-
-
Notifications
You must be signed in to change notification settings - Fork 116
Description
Feature Request
In the current Infinite
type under @kubb/plugin-react-query
, we only have queryParam
and (optionally) a cursorParam
. It would be helpful to support both nextParam
and previousParam
separately for more flexible pagination handling, especially in APIs that provide both directions.
Proposed enhancement
Extend the Infinite
type to include:
export type Infinite = {
queryParam: string
nextParam?: string | string[]
previousParam?: string | string[]
initialPageParam: unknown
}
- nextParam: used to extract the cursor for the next page.
- previousParam: used to extract the cursor for the previous page, useful for bidirectional pagination.
- Both could support dot notation or an array path to access nested fields, e.g.
'data.next.id'
or['data', 'next', 'id']
.
Why this matters
Many paginated APIs return both next and previous cursors, and being able to access them independently — especially when they’re nested — would improve the usability and adaptability of the useInfiniteQuery config generation.
Example use case:
{
"data": [...],
"pagination": {
"next": { "id": "abc123" },
"prev": { "id": "xyz789" }
}
}
With:
nextParam: ['pagination', 'next', 'id']
previousParam: ['pagination', 'prev', 'id']
This would allow codegen to correctly extract the right cursor depending on direction and aligns with how getNextPageParam
and getPreviousPageParam
are used in TanStack Query.