feat(openapi-react-query): generate useInfiniteQuery hooks for paginated endpoints#281
Merged
Merged
Conversation
…ted endpoints (#189) Emits a useXxxInfinite hook alongside the regular useQuery hook whenever a list-level GET operation is detected as paginated. Fully additive and non-breaking: the regular hook is always generated unchanged. Detection priority: 1. x-infinite: true/false on the operation (explicit override). 2. Heuristic: list GET (no path params) with a recognised pagination query param name (page, cursor, offset, pageToken, after, before, next_page, nextPage, page_token). Detection runs on resolved $ref params. 3. infiniteQuery config field (boolean | 'auto', default 'auto') allows force-on, force-off, or heuristic mode. Generated hook shape: - Named use${funcName}Infinite (mirrors useSuspense* suffix pattern). - queryKey: [...resourceKeys.list(params), 'infinite'] to namespace away from regular list queries. - queryFn injects pageParam into the params object at the detected param name. - Provides initialPageParam: undefined and getNextPageParam: () => undefined as defaults; callers override both via the options argument. - options type: Omit<UseInfiniteQueryOptions<...>, 'queryKey' | 'queryFn'> so callers can supply getNextPageParam and initialPageParam. Config: added infinite_query field to ReactQueryConfig with validation. Regenerated: packages/integration/generated/hooks.ts (gains useListTasksInfinite), and 6 showcase specs in examples/generated-rq/ that have pagination params (1password-connect, devto, openai, redocly-museum, resend, spotify).
Contributor
Fallow audit reportFound 18 findings. Dependencies (2)
Duplication (15)
Health (1)
Generated by fallow. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #189.
This is an additive, non-breaking feature that generates
useInfiniteQueryhooks for paginated endpoints.Detection Strategy
The feature uses a three-level priority system:
Operation Extension (highest priority):
x-infinite: true/falseon an operation. This wins even on detail endpoints. Warns and skips silently if detected but no query params exist.Heuristic Detection: For GET list operations without path params, detects pagination param names (page, cursor, offset, pageToken, after, before, etc.).
Configuration Field: New
infinite_queryconfig field (boolean | 'auto', default 'auto') allows explicit control.Generated Hooks
use{Name}Infinite(e.g.,useItemsInfinite)queryFnmergespageParaminto the detected pagination paramgetNextPageParamandinitialPageParamomitted from required surface, but overridable at runtime via options spread)Testing & Output
Code Review
This change went through internal code review with 2 blocking findings fixed:
x-infinitedetected but pagination params missing (now warns)