openapi-react-query-codegen icon indicating copy to clipboard operation
openapi-react-query-codegen copied to clipboard

Generate `useInfiniteQuery` that accepts custom getNextPageParam callback

Open superxiao opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. Current useInfiniteQuery is great, however in some cases the response won't conveniently contain a nextPageParam parameter. Notable example being Spring Page responses, which serializes to something like the following:

{
  "content": [
    {
      "name": null,
      "price": null
    }
  ],
  "pageable": {
    "pageNumber": 0,
    "pageSize": 20,
    "sort": {
      "empty": true,
      "unsorted": true,
      "sorted": false
    },
    "offset": 0,
    "unpaged": false,
    "paged": true
  },
  "last": false,
  "totalElements": 100,
  "totalPages": 5,
  "first": true,
  "size": 20,
  "number": 0,
  "sort": {
    "empty": true,
    "unsorted": true,
    "sorted": false
  },
  "numberOfElements": 1,
  "empty": false
}

I tried but found no way to customize the springdoc behavior to generate something like a nextPage in this format.

Describe the solution you'd like Have a CLI option to generate useInfiniteQuery which accepts a getNextPageParam callback that I can implement in the frontend.

Describe alternatives you've considered Cannot think of any at the moment.

Additional context There is also a PagedModel in Spring, however this does not contain a next page number field either. It contains a nextLink instead.

My current use case more pertains to the Page response.

superxiao avatar Nov 30 '24 15:11 superxiao