@@ -4,17 +4,17 @@ import type {
44 QueryFunctionContext ,
55} from '@tanstack/react-query' ;
66
7- import {
8- type DataSourceContext ,
9- type DataSourceData ,
10- type DataSourceError ,
11- type DataSourceKey ,
12- type DataSourceOptions ,
13- type DataSourceParams ,
14- type DataSourceResponse ,
15- type DataSourceState ,
16- composeFullKey ,
17- idle ,
7+ import { composeFullKey , idle } from '../../../core' ;
8+ import type {
9+ DataSourceContext ,
10+ DataSourceData ,
11+ DataSourceError ,
12+ DataSourceKey ,
13+ DataSourceOptions ,
14+ DataSourceParams ,
15+ DataSourceRequest ,
16+ DataSourceResponse ,
17+ DataSourceState ,
1818} from '../../../core' ;
1919import { normalizeStatus } from '../../utils/normalizeStatus' ;
2020
@@ -40,31 +40,24 @@ export const composeOptions = <TDataSource extends AnyInfiniteQueryDataSource>(
4040 enabled : params !== idle ,
4141 queryKey : composeFullKey ( dataSource , params ) ,
4242 queryFn : (
43- fetchContext : QueryFunctionContext < DataSourceKey , DataSourceParams < TDataSource > > ,
43+ fetchContext : QueryFunctionContext <
44+ DataSourceKey ,
45+ Partial < DataSourceRequest < TDataSource > > | undefined
46+ > ,
4447 ) => {
45- const actualParams = fetchContext . pageParam ?? params ;
48+ const actualParams = transformParams ? transformParams ( params ) : params ;
49+ const request =
50+ typeof actualParams === 'object'
51+ ? { ...actualParams , ...fetchContext . pageParam }
52+ : actualParams ;
4653
47- return dataSource . fetch (
48- context ,
49- fetchContext ,
50- transformParams ? transformParams ( actualParams ) : actualParams ,
51- ) ;
54+ return dataSource . fetch ( context , fetchContext , request ) ;
5255 } ,
5356 select : transformResponse
5457 ? ( data ) => ( { ...data , pages : data . pages . map ( transformResponse ) } )
5558 : undefined ,
56- getNextPageParam : ( lastPage , allPages ) => {
57- const nextParamsPatch = next ( lastPage , allPages ) ;
58-
59- return nextParamsPatch ? { ...params , ...nextParamsPatch } : undefined ;
60- } ,
61- getPreviousPageParam : prev
62- ? ( firstPage , allPages ) => {
63- const prevParamsPatch = prev ( firstPage , allPages ) ;
64-
65- return prevParamsPatch ? { ...params , ...prevParamsPatch } : undefined ;
66- }
67- : undefined ,
59+ getNextPageParam : next ,
60+ getPreviousPageParam : prev ,
6861 ...options ,
6962 } ;
7063} ;
0 commit comments