You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generates incorrect queryKeys for Infinite queries #140
Describe the bug
Generates incorrect queryKeys for Infinite queries, the page is expected to be sent into the KeyFn.
To Reproduce
Steps to reproduce the behavior:
Generate client using openapi-rq --pageParam page --input https://localhost:44353/swagger/v1/swagger.json --output src/openapi/.
Compile code 💥
Expected behavior
I think you need 2 sets for KeyFn functions one for Infinite queries and one for the normal request.
Where the Infinite version excludes the page.
Infinite queries now get their own key constant and key function, separate from the plain query ones, and the page parameter is excluded from the infinite key at the type level:
The page value is threaded into the request only (query: { ...clientOptions.query, page: pageParam }), never into the key — so the key stays stable across pages, which is the behaviour TanStack Query expects.
Note the infinite key nests the plain key as its first segment. That means invalidateQueries({ queryKey: [useFindPaginatedPetsKey] }) still matches both caches, while the "infinite" segment keeps cached InfiniteData from colliding with plain query data.
A custom page-param name (--pageParam) is respected in the Omit. Available on latest (npm i @7nohe/openapi-react-query-codegen@3). Thanks for the clear report — the two-key-set design is exactly what you proposed.
Activity
[-]generates incorrect queryKeys for Infinite queries[/-][+]Generates incorrect queryKeys for Infinite queries[/+]hanahem commentedon Aug 20, 2024
Oh thanks for raising this one, I think it causes the issue I raised here:
#139
feat: generate queryOptions/infiniteQueryOptions factories and dedica…
feat!: hierarchical infinite query keys for granular invalidation
7nohe commentedon Aug 11, 2026
Fixed in v3.0.0.
Infinite queries now get their own key constant and key function, separate from the plain query ones, and the page parameter is excluded from the infinite key at the type level:
The page value is threaded into the request only (
query: { ...clientOptions.query, page: pageParam }), never into the key — so the key stays stable across pages, which is the behaviour TanStack Query expects.Note the infinite key nests the plain key as its first segment. That means
invalidateQueries({ queryKey: [useFindPaginatedPetsKey] })still matches both caches, while the"infinite"segment keeps cachedInfiniteDatafrom colliding with plain query data.A custom page-param name (
--pageParam) is respected in theOmit. Available onlatest(npm i @7nohe/openapi-react-query-codegen@3). Thanks for the clear report — the two-key-set design is exactly what you proposed.