Skip to content

initialPageParam in useInfiniteQuery shouldn't default to zero #2340

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

Open
1 task done
mevansAI opened this issue May 28, 2025 · 0 comments
Open
1 task done

initialPageParam in useInfiniteQuery shouldn't default to zero #2340

mevansAI opened this issue May 28, 2025 · 0 comments
Labels
enhancement New feature or request openapi-react-query Relevant to openapi-react-query

Comments

@mevansAI
Copy link

Description

Currently pageParam in use infinite query is set to 0 if initialPageParam is undefined. While this makes sense in some cases, the backend my react app is fetching from uses mikro-orms implementation of a cursor, where the cursor is represented by an opaque string rather than a sequential number, so the correct way to get the 1st page in my implementation is to omit a cursor value completely from the request (and then use the response from that query to get the cursor for the subsequent pages).

Currently this library doesn't support that implementation as if I set initialPageParam: undefined it will set pageParam to 0 and send api-endpoint?cursor=0 in the http request to my backend api which will throw an error.

Proposal

  • Remove the default value of 0 for pageParam. Consequence of this is if a default value of zero is required it must be explicitly set as initialPageParam: 0
    OR
  • Provide an option to override this default value or omit cursor from the http request

Any other suggestions are welcome.

Extra

@mevansAI mevansAI added enhancement New feature or request openapi-react-query Relevant to openapi-react-query labels May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-react-query Relevant to openapi-react-query
Projects
None yet
Development

No branches or pull requests

1 participant