Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate useInfiniteQuery that accepts custom getNextPageParam callback #175

Open
superxiao opened this issue Nov 30, 2024 · 0 comments
Open

Comments

@superxiao
Copy link

superxiao commented Nov 30, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant