-
-
Notifications
You must be signed in to change notification settings - Fork 529
Closed
Copy link
Description
Description
The current SWR integration in Orval doesn't properly support useSWRInfinite pagination. The generated swrKeyLoader function doesn't accept the required pageIndex and previousPageData parameters that SWR Infinite expects, making infinite pagination impossible to implement.
Expected Behavior
The generated swrKeyLoader should:
- Accept
pageIndexandpreviousPageDataparameters from useSWRInfinite - Pass these parameters to the underlying key loader function
- Enable proper infinite pagination functionality
Current Behavior
The generated code creates a swrKeyLoader that doesn't accept any parameters:
const swrKeyLoader = swrOptions?.swrKeyLoader ?? (() => isEnabled ? getOperationInfiniteKeyLoader(params) : null);This prevents useSWRInfinite from working correctly because it can't pass pagination parameters to determine the next page key.
Steps to Reproduce
- Configure Orval to generate SWR hooks with
useInfinite: true - Try to use the generated infinite hook
- Notice that pagination doesn't work because
pageIndexandpreviousPageDataare not available
Proposed Solution
The swrKeyLoader should be generated as:
const swrKeyLoader = swrOptions?.swrKeyLoader ?? ((pageIndex, previousPageData) => isEnabled ? getOperationInfiniteKeyLoader(params)(pageIndex, previousPageData) : null);const swrFn = ([_url, params]) => operationName(params);Environment
- Orval version: 7.9.0
- SWR version: Latest
- TypeScript version: Latest
Metadata
Metadata
Assignees
Labels
swrSWR related issuesSWR related issues