Skip to content

Generate useInfiniteQuery that accepts custom getNextPageParam callback #175

@superxiao

Description

@superxiao

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions