@@ -96,8 +96,34 @@ export type UseInfiniteQueryMethod<Paths extends Record<string, Record<HttpMetho
96
96
method : Method ,
97
97
url : Path ,
98
98
...[ init , options , queryClient ] : RequiredKeysOf < Init > extends never
99
- ? [ InitWithUnknowns < Init > ?, Omit < UseInfiniteQueryOptions < Response [ "data" ] , Response [ "error" ] , Response [ "data" ] , number , QueryKey < Paths , Method , Path > > , "queryKey" | "queryFn" > ?, QueryClient ?]
100
- : [ InitWithUnknowns < Init > , Omit < UseInfiniteQueryOptions < Response [ "data" ] , Response [ "error" ] , Response [ "data" ] , number , QueryKey < Paths , Method , Path > > , "queryKey" | "queryFn" > ?, QueryClient ?]
99
+ ? [
100
+ InitWithUnknowns < Init > ?,
101
+ Omit <
102
+ UseInfiniteQueryOptions <
103
+ Response [ "data" ] ,
104
+ Response [ "error" ] ,
105
+ Response [ "data" ] ,
106
+ number ,
107
+ QueryKey < Paths , Method , Path >
108
+ > ,
109
+ "queryKey" | "queryFn"
110
+ > ?,
111
+ QueryClient ?,
112
+ ]
113
+ : [
114
+ InitWithUnknowns < Init > ,
115
+ Omit <
116
+ UseInfiniteQueryOptions <
117
+ Response [ "data" ] ,
118
+ Response [ "error" ] ,
119
+ Response [ "data" ] ,
120
+ number ,
121
+ QueryKey < Paths , Method , Path >
122
+ > ,
123
+ "queryKey" | "queryFn"
124
+ > ?,
125
+ QueryClient ?,
126
+ ]
101
127
) => UseInfiniteQueryResult < Response [ "data" ] , Response [ "error" ] > ;
102
128
103
129
export type UseMutationMethod < Paths extends Record < string , Record < HttpMethod , { } > > , Media extends MediaType > = <
@@ -145,22 +171,30 @@ export default function createClient<Paths extends {}, Media extends MediaType =
145
171
...options ,
146
172
} ) ;
147
173
148
-
149
174
const infiniteQueryOptions = <
150
- Method extends HttpMethod ,
151
- Path extends PathsWithMethod < Paths , Method > ,
152
- Init extends MaybeOptionalInit < Paths [ Path ] , Method & keyof Paths [ Path ] > ,
153
- Response extends Required < FetchResponse < any , Init , Media > > ,
154
- > (
155
- method : Method ,
156
- path : Path ,
157
- init ?: InitWithUnknowns < Init > ,
158
- options ?: Omit < UseInfiniteQueryOptions < Response [ "data" ] , Response [ "error" ] , Response [ "data" ] , number , QueryKey < Paths , Method , Path > > , "queryKey" | "queryFn" >
159
- ) => ( {
160
- queryKey : [ method , path , init ] as const ,
161
- queryFn,
162
- ...options ,
163
- } ) ;
175
+ Method extends HttpMethod ,
176
+ Path extends PathsWithMethod < Paths , Method > ,
177
+ Init extends MaybeOptionalInit < Paths [ Path ] , Method & keyof Paths [ Path ] > ,
178
+ Response extends Required < FetchResponse < any , Init , Media > > ,
179
+ > (
180
+ method : Method ,
181
+ path : Path ,
182
+ init ?: InitWithUnknowns < Init > ,
183
+ options ?: Omit <
184
+ UseInfiniteQueryOptions <
185
+ Response [ "data" ] ,
186
+ Response [ "error" ] ,
187
+ Response [ "data" ] ,
188
+ number ,
189
+ QueryKey < Paths , Method , Path >
190
+ > ,
191
+ "queryKey" | "queryFn"
192
+ > ,
193
+ ) => ( {
194
+ queryKey : [ method , path , init ] as const ,
195
+ queryFn,
196
+ ...options ,
197
+ } ) ;
164
198
165
199
return {
166
200
queryOptions,
@@ -170,12 +204,15 @@ export default function createClient<Paths extends {}, Media extends MediaType =
170
204
useSuspenseQuery ( queryOptions ( method , path , init as InitWithUnknowns < typeof init > , options ) , queryClient ) ,
171
205
useInfiniteQuery : ( method , path , ...[ init , options , queryClient ] ) => {
172
206
const baseOptions = infiniteQueryOptions ( method , path , init as InitWithUnknowns < typeof init > , options as any ) ; // TODO: find a way to avoid as any
173
- return useInfiniteQuery ( {
174
- ...baseOptions ,
175
- initialPageParam : 0 ,
176
- getNextPageParam : ( lastPage : any , allPages : any [ ] , lastPageParam : number , allPageParams : number [ ] ) =>
177
- options ?. getNextPageParam ?.( lastPage , allPages , lastPageParam , allPageParams ) ?? allPages . length ,
178
- } as any , queryClient ) ;
207
+ return useInfiniteQuery (
208
+ {
209
+ ...baseOptions ,
210
+ initialPageParam : 0 ,
211
+ getNextPageParam : ( lastPage : any , allPages : any [ ] , lastPageParam : number , allPageParams : number [ ] ) =>
212
+ options ?. getNextPageParam ?.( lastPage , allPages , lastPageParam , allPageParams ) ?? allPages . length ,
213
+ } as any ,
214
+ queryClient ,
215
+ ) ;
179
216
} ,
180
217
useMutation : ( method , path , options , queryClient ) =>
181
218
useMutation (
0 commit comments