6
6
*/
7
7
import { useInfiniteQuery , useMutation , useQuery } from '@tanstack/vue-query' ;
8
8
import type {
9
+ InfiniteData ,
9
10
MutationFunction ,
10
11
QueryFunction ,
11
12
QueryKey ,
@@ -54,27 +55,36 @@ export const getListPetsQueryKey = (
54
55
} ;
55
56
56
57
export const getListPetsInfiniteQueryOptions = <
57
- TData = Awaited < ReturnType < typeof listPets > > ,
58
+ TData = InfiniteData <
59
+ Awaited < ReturnType < typeof listPets > > ,
60
+ ListPetsParams [ 'limit' ]
61
+ > ,
58
62
TError = Error ,
59
63
> (
60
64
params ?: MaybeRef < ListPetsParams > ,
61
65
version : MaybeRef < number | undefined | null > = 1 ,
62
66
options ?: {
63
- query ?: UseInfiniteQueryOptions <
64
- Awaited < ReturnType < typeof listPets > > ,
65
- TError ,
66
- TData
67
+ query ?: Partial <
68
+ UseInfiniteQueryOptions <
69
+ Awaited < ReturnType < typeof listPets > > ,
70
+ TError ,
71
+ TData ,
72
+ Awaited < ReturnType < typeof listPets > > ,
73
+ QueryKey ,
74
+ ListPetsParams [ 'limit' ]
75
+ >
67
76
> ;
68
77
} ,
69
78
) => {
70
79
const { query : queryOptions } = options ?? { } ;
71
80
72
81
const queryKey = getListPetsQueryKey ( params , version ) ;
73
82
74
- const queryFn : QueryFunction < Awaited < ReturnType < typeof listPets > > > = ( {
75
- signal,
76
- pageParam,
77
- } ) =>
83
+ const queryFn : QueryFunction <
84
+ Awaited < ReturnType < typeof listPets > > ,
85
+ QueryKey ,
86
+ ListPetsParams [ 'limit' ]
87
+ > = ( { signal, pageParam } ) =>
78
88
listPets (
79
89
{ ...params , limit : pageParam || unref ( params ) ?. [ 'limit' ] } ,
80
90
version ,
@@ -89,7 +99,10 @@ export const getListPetsInfiniteQueryOptions = <
89
99
} as UseInfiniteQueryOptions <
90
100
Awaited < ReturnType < typeof listPets > > ,
91
101
TError ,
92
- TData
102
+ TData ,
103
+ Awaited < ReturnType < typeof listPets > > ,
104
+ QueryKey ,
105
+ ListPetsParams [ 'limit' ]
93
106
> ;
94
107
} ;
95
108
@@ -102,16 +115,24 @@ export type ListPetsInfiniteQueryError = Error;
102
115
* @summary List all pets
103
116
*/
104
117
export const useListPetsInfinite = <
105
- TData = Awaited < ReturnType < typeof listPets > > ,
118
+ TData = InfiniteData <
119
+ Awaited < ReturnType < typeof listPets > > ,
120
+ ListPetsParams [ 'limit' ]
121
+ > ,
106
122
TError = Error ,
107
123
> (
108
124
params ?: MaybeRef < ListPetsParams > ,
109
125
version : MaybeRef < number | undefined | null > = 1 ,
110
126
options ?: {
111
- query ?: UseInfiniteQueryOptions <
112
- Awaited < ReturnType < typeof listPets > > ,
113
- TError ,
114
- TData
127
+ query ?: Partial <
128
+ UseInfiniteQueryOptions <
129
+ Awaited < ReturnType < typeof listPets > > ,
130
+ TError ,
131
+ TData ,
132
+ Awaited < ReturnType < typeof listPets > > ,
133
+ QueryKey ,
134
+ ListPetsParams [ 'limit' ]
135
+ >
115
136
> ;
116
137
} ,
117
138
) : UseInfiniteQueryReturnType < TData , TError > & { queryKey : QueryKey } => {
@@ -126,7 +147,7 @@ export const useListPetsInfinite = <
126
147
TError
127
148
> & { queryKey : QueryKey } ;
128
149
129
- query . queryKey = queryOptions . queryKey as QueryKey ;
150
+ query . queryKey = unref ( queryOptions ) . queryKey as QueryKey ;
130
151
131
152
return query ;
132
153
} ;
@@ -138,10 +159,8 @@ export const getListPetsQueryOptions = <
138
159
params ?: MaybeRef < ListPetsParams > ,
139
160
version : MaybeRef < number | undefined | null > = 1 ,
140
161
options ?: {
141
- query ?: UseQueryOptions <
142
- Awaited < ReturnType < typeof listPets > > ,
143
- TError ,
144
- TData
162
+ query ?: Partial <
163
+ UseQueryOptions < Awaited < ReturnType < typeof listPets > > , TError , TData >
145
164
> ;
146
165
} ,
147
166
) => {
@@ -176,10 +195,8 @@ export const useListPets = <
176
195
params ?: MaybeRef < ListPetsParams > ,
177
196
version : MaybeRef < number | undefined | null > = 1 ,
178
197
options ?: {
179
- query ?: UseQueryOptions <
180
- Awaited < ReturnType < typeof listPets > > ,
181
- TError ,
182
- TData
198
+ query ?: Partial <
199
+ UseQueryOptions < Awaited < ReturnType < typeof listPets > > , TError , TData >
183
200
> ;
184
201
} ,
185
202
) : UseQueryReturnType < TData , TError > & { queryKey : QueryKey } => {
@@ -189,7 +206,7 @@ export const useListPets = <
189
206
queryKey : QueryKey ;
190
207
} ;
191
208
192
- query . queryKey = queryOptions . queryKey as QueryKey ;
209
+ query . queryKey = unref ( queryOptions ) . queryKey as QueryKey ;
193
210
194
211
return query ;
195
212
} ;
@@ -297,16 +314,18 @@ export const getShowPetByIdQueryKey = (
297
314
} ;
298
315
299
316
export const getShowPetByIdInfiniteQueryOptions = <
300
- TData = Awaited < ReturnType < typeof showPetById > > ,
317
+ TData = InfiniteData < Awaited < ReturnType < typeof showPetById > > > ,
301
318
TError = Error ,
302
319
> (
303
320
petId : MaybeRef < string | undefined | null > ,
304
321
version : MaybeRef < number | undefined | null > = 1 ,
305
322
options ?: {
306
- query ?: UseInfiniteQueryOptions <
307
- Awaited < ReturnType < typeof showPetById > > ,
308
- TError ,
309
- TData
323
+ query ?: Partial <
324
+ UseInfiniteQueryOptions <
325
+ Awaited < ReturnType < typeof showPetById > > ,
326
+ TError ,
327
+ TData
328
+ >
310
329
> ;
311
330
} ,
312
331
) => {
@@ -339,16 +358,18 @@ export type ShowPetByIdInfiniteQueryError = Error;
339
358
* @summary Info for a specific pet
340
359
*/
341
360
export const useShowPetByIdInfinite = <
342
- TData = Awaited < ReturnType < typeof showPetById > > ,
361
+ TData = InfiniteData < Awaited < ReturnType < typeof showPetById > > > ,
343
362
TError = Error ,
344
363
> (
345
364
petId : MaybeRef < string | undefined | null > ,
346
365
version : MaybeRef < number | undefined | null > = 1 ,
347
366
options ?: {
348
- query ?: UseInfiniteQueryOptions <
349
- Awaited < ReturnType < typeof showPetById > > ,
350
- TError ,
351
- TData
367
+ query ?: Partial <
368
+ UseInfiniteQueryOptions <
369
+ Awaited < ReturnType < typeof showPetById > > ,
370
+ TError ,
371
+ TData
372
+ >
352
373
> ;
353
374
} ,
354
375
) : UseInfiniteQueryReturnType < TData , TError > & { queryKey : QueryKey } => {
@@ -363,7 +384,7 @@ export const useShowPetByIdInfinite = <
363
384
TError
364
385
> & { queryKey : QueryKey } ;
365
386
366
- query . queryKey = queryOptions . queryKey as QueryKey ;
387
+ query . queryKey = unref ( queryOptions ) . queryKey as QueryKey ;
367
388
368
389
return query ;
369
390
} ;
@@ -375,10 +396,8 @@ export const getShowPetByIdQueryOptions = <
375
396
petId : MaybeRef < string | undefined | null > ,
376
397
version : MaybeRef < number | undefined | null > = 1 ,
377
398
options ?: {
378
- query ?: UseQueryOptions <
379
- Awaited < ReturnType < typeof showPetById > > ,
380
- TError ,
381
- TData
399
+ query ?: Partial <
400
+ UseQueryOptions < Awaited < ReturnType < typeof showPetById > > , TError , TData >
382
401
> ;
383
402
} ,
384
403
) => {
@@ -413,10 +432,8 @@ export const useShowPetById = <
413
432
petId : MaybeRef < string | undefined | null > ,
414
433
version : MaybeRef < number | undefined | null > = 1 ,
415
434
options ?: {
416
- query ?: UseQueryOptions <
417
- Awaited < ReturnType < typeof showPetById > > ,
418
- TError ,
419
- TData
435
+ query ?: Partial <
436
+ UseQueryOptions < Awaited < ReturnType < typeof showPetById > > , TError , TData >
420
437
> ;
421
438
} ,
422
439
) : UseQueryReturnType < TData , TError > & { queryKey : QueryKey } => {
@@ -426,7 +443,7 @@ export const useShowPetById = <
426
443
queryKey : QueryKey ;
427
444
} ;
428
445
429
- query . queryKey = queryOptions . queryKey as QueryKey ;
446
+ query . queryKey = unref ( queryOptions ) . queryKey as QueryKey ;
430
447
431
448
return query ;
432
449
} ;
0 commit comments