@@ -40,19 +40,23 @@ const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions
4040 return [ params ] ;
4141} ;
4242
43+ const resolveOptions = < T > ( options : T | typeof skipToken ) => options === skipToken ? undefined : options ;
44+
45+ const resolveQueryFn = < T > ( options : T | typeof skipToken , queryFn : T ) => options === skipToken ? skipToken : queryFn ;
46+
4347export const serviceWithEmptyTagQueryKey = ( options ?: Options < ServiceWithEmptyTagData > ) => createQueryKey ( 'serviceWithEmptyTag' , options ) ;
4448
4549export const serviceWithEmptyTagOptions = ( options ?: Options < ServiceWithEmptyTagData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof serviceWithEmptyTagQueryKey > > ( {
46- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
50+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
4751 const { data } = await serviceWithEmptyTag ( {
4852 ...options ,
4953 ...queryKey [ 0 ] ,
5054 signal,
5155 throwOnError : true
5256 } ) ;
5357 return data ;
54- } ,
55- queryKey : serviceWithEmptyTagQueryKey ( options === skipToken ? undefined as never : options )
58+ } ) ,
59+ queryKey : serviceWithEmptyTagQueryKey ( resolveOptions ( options ) )
5660} ) ;
5761
5862export const patchApiVbyApiVersionNoTagMutation = ( options ?: Partial < Options < PatchApiVbyApiVersionNoTagData > > ) : MutationOptions < unknown , AxiosError < DefaultError > , Options < PatchApiVbyApiVersionNoTagData > > => {
@@ -100,16 +104,16 @@ export const deleteCallWithoutParametersAndResponseMutation = (options?: Partial
100104export const getCallWithoutParametersAndResponseQueryKey = ( options ?: Options < GetCallWithoutParametersAndResponseData > ) => createQueryKey ( 'getCallWithoutParametersAndResponse' , options ) ;
101105
102106export const getCallWithoutParametersAndResponseOptions = ( options ?: Options < GetCallWithoutParametersAndResponseData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof getCallWithoutParametersAndResponseQueryKey > > ( {
103- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
107+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
104108 const { data } = await getCallWithoutParametersAndResponse ( {
105109 ...options ,
106110 ...queryKey [ 0 ] ,
107111 signal,
108112 throwOnError : true
109113 } ) ;
110114 return data ;
111- } ,
112- queryKey : getCallWithoutParametersAndResponseQueryKey ( options === skipToken ? undefined as never : options )
115+ } ) ,
116+ queryKey : getCallWithoutParametersAndResponseQueryKey ( resolveOptions ( options ) )
113117} ) ;
114118
115119export const patchCallWithoutParametersAndResponseMutation = ( options ?: Partial < Options < PatchCallWithoutParametersAndResponseData > > ) : MutationOptions < unknown , AxiosError < DefaultError > , Options < PatchCallWithoutParametersAndResponseData > > => {
@@ -199,16 +203,16 @@ export const callWithWeirdParameterNamesMutation = (options?: Partial<Options<Ca
199203export const callWithDefaultParametersQueryKey = ( options : Options < CallWithDefaultParametersData > ) => createQueryKey ( 'callWithDefaultParameters' , options ) ;
200204
201205export const callWithDefaultParametersOptions = ( options : Options < CallWithDefaultParametersData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof callWithDefaultParametersQueryKey > > ( {
202- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
206+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
203207 const { data } = await callWithDefaultParameters ( {
204208 ...options ,
205209 ...queryKey [ 0 ] ,
206210 signal,
207211 throwOnError : true
208212 } ) ;
209213 return data ;
210- } ,
211- queryKey : callWithDefaultParametersQueryKey ( options === skipToken ? undefined as never : options )
214+ } ) ,
215+ queryKey : callWithDefaultParametersQueryKey ( resolveOptions ( options ) )
212216} ) ;
213217
214218export const callWithDefaultOptionalParametersMutation = ( options ?: Partial < Options < CallWithDefaultOptionalParametersData > > ) : MutationOptions < unknown , AxiosError < DefaultError > , Options < CallWithDefaultOptionalParametersData > > => {
@@ -256,16 +260,16 @@ export const duplicateNameMutation = (options?: Partial<Options<DuplicateNameDat
256260export const duplicateName2QueryKey = ( options ?: Options < DuplicateName2Data > ) => createQueryKey ( 'duplicateName2' , options ) ;
257261
258262export const duplicateName2Options = ( options ?: Options < DuplicateName2Data > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof duplicateName2QueryKey > > ( {
259- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
263+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
260264 const { data } = await duplicateName2 ( {
261265 ...options ,
262266 ...queryKey [ 0 ] ,
263267 signal,
264268 throwOnError : true
265269 } ) ;
266270 return data ;
267- } ,
268- queryKey : duplicateName2QueryKey ( options === skipToken ? undefined as never : options )
271+ } ) ,
272+ queryKey : duplicateName2QueryKey ( resolveOptions ( options ) )
269273} ) ;
270274
271275export const duplicateName3Mutation = ( options ?: Partial < Options < DuplicateName3Data > > ) : MutationOptions < unknown , AxiosError < DefaultError > , Options < DuplicateName3Data > > => {
@@ -299,76 +303,76 @@ export const duplicateName4Mutation = (options?: Partial<Options<DuplicateName4D
299303export const callWithNoContentResponseQueryKey = ( options ?: Options < CallWithNoContentResponseData > ) => createQueryKey ( 'callWithNoContentResponse' , options ) ;
300304
301305export const callWithNoContentResponseOptions = ( options ?: Options < CallWithNoContentResponseData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof callWithNoContentResponseQueryKey > > ( {
302- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
306+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
303307 const { data } = await callWithNoContentResponse ( {
304308 ...options ,
305309 ...queryKey [ 0 ] ,
306310 signal,
307311 throwOnError : true
308312 } ) ;
309313 return data ;
310- } ,
311- queryKey : callWithNoContentResponseQueryKey ( options === skipToken ? undefined as never : options )
314+ } ) ,
315+ queryKey : callWithNoContentResponseQueryKey ( resolveOptions ( options ) )
312316} ) ;
313317
314318export const callWithResponseAndNoContentResponseQueryKey = ( options ?: Options < CallWithResponseAndNoContentResponseData > ) => createQueryKey ( 'callWithResponseAndNoContentResponse' , options ) ;
315319
316320export const callWithResponseAndNoContentResponseOptions = ( options ?: Options < CallWithResponseAndNoContentResponseData > | typeof skipToken ) => queryOptions < CallWithResponseAndNoContentResponseResponse , AxiosError < DefaultError > , CallWithResponseAndNoContentResponseResponse , ReturnType < typeof callWithResponseAndNoContentResponseQueryKey > > ( {
317- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
321+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
318322 const { data } = await callWithResponseAndNoContentResponse ( {
319323 ...options ,
320324 ...queryKey [ 0 ] ,
321325 signal,
322326 throwOnError : true
323327 } ) ;
324328 return data ;
325- } ,
326- queryKey : callWithResponseAndNoContentResponseQueryKey ( options === skipToken ? undefined as never : options )
329+ } ) ,
330+ queryKey : callWithResponseAndNoContentResponseQueryKey ( resolveOptions ( options ) )
327331} ) ;
328332
329333export const dummyAQueryKey = ( options ?: Options < DummyAData > ) => createQueryKey ( 'dummyA' , options ) ;
330334
331335export const dummyAOptions = ( options ?: Options < DummyAData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof dummyAQueryKey > > ( {
332- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
336+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
333337 const { data } = await dummyA ( {
334338 ...options ,
335339 ...queryKey [ 0 ] ,
336340 signal,
337341 throwOnError : true
338342 } ) ;
339343 return data ;
340- } ,
341- queryKey : dummyAQueryKey ( options === skipToken ? undefined as never : options )
344+ } ) ,
345+ queryKey : dummyAQueryKey ( resolveOptions ( options ) )
342346} ) ;
343347
344348export const dummyBQueryKey = ( options ?: Options < DummyBData > ) => createQueryKey ( 'dummyB' , options ) ;
345349
346350export const dummyBOptions = ( options ?: Options < DummyBData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof dummyBQueryKey > > ( {
347- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
351+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
348352 const { data } = await dummyB ( {
349353 ...options ,
350354 ...queryKey [ 0 ] ,
351355 signal,
352356 throwOnError : true
353357 } ) ;
354358 return data ;
355- } ,
356- queryKey : dummyBQueryKey ( options === skipToken ? undefined as never : options )
359+ } ) ,
360+ queryKey : dummyBQueryKey ( resolveOptions ( options ) )
357361} ) ;
358362
359363export const callWithResponseQueryKey = ( options ?: Options < CallWithResponseData > ) => createQueryKey ( 'callWithResponse' , options ) ;
360364
361365export const callWithResponseOptions = ( options ?: Options < CallWithResponseData > | typeof skipToken ) => queryOptions < CallWithResponseResponse , AxiosError < DefaultError > , CallWithResponseResponse , ReturnType < typeof callWithResponseQueryKey > > ( {
362- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
366+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
363367 const { data } = await callWithResponse ( {
364368 ...options ,
365369 ...queryKey [ 0 ] ,
366370 signal,
367371 throwOnError : true
368372 } ) ;
369373 return data ;
370- } ,
371- queryKey : callWithResponseQueryKey ( options === skipToken ? undefined as never : options )
374+ } ) ,
375+ queryKey : callWithResponseQueryKey ( resolveOptions ( options ) )
372376} ) ;
373377
374378export const callWithDuplicateResponsesMutation = ( options ?: Partial < Options < CallWithDuplicateResponsesData > > ) : MutationOptions < CallWithDuplicateResponsesResponse , AxiosError < CallWithDuplicateResponsesError > , Options < CallWithDuplicateResponsesData > > => {
@@ -402,46 +406,46 @@ export const callWithResponsesMutation = (options?: Partial<Options<CallWithResp
402406export const collectionFormatQueryKey = ( options : Options < CollectionFormatData > ) => createQueryKey ( 'collectionFormat' , options ) ;
403407
404408export const collectionFormatOptions = ( options : Options < CollectionFormatData > | typeof skipToken ) => queryOptions < unknown , AxiosError < DefaultError > , unknown , ReturnType < typeof collectionFormatQueryKey > > ( {
405- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
409+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
406410 const { data } = await collectionFormat ( {
407411 ...options ,
408412 ...queryKey [ 0 ] ,
409413 signal,
410414 throwOnError : true
411415 } ) ;
412416 return data ;
413- } ,
414- queryKey : collectionFormatQueryKey ( options === skipToken ? undefined as never : options )
417+ } ) ,
418+ queryKey : collectionFormatQueryKey ( resolveOptions ( options ) )
415419} ) ;
416420
417421export const typesQueryKey = ( options : Options < TypesData > ) => createQueryKey ( 'types' , options ) ;
418422
419423export const typesOptions = ( options : Options < TypesData > | typeof skipToken ) => queryOptions < TypesResponse , AxiosError < DefaultError > , TypesResponse , ReturnType < typeof typesQueryKey > > ( {
420- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
424+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
421425 const { data } = await types ( {
422426 ...options ,
423427 ...queryKey [ 0 ] ,
424428 signal,
425429 throwOnError : true
426430 } ) ;
427431 return data ;
428- } ,
429- queryKey : typesQueryKey ( options === skipToken ? undefined as never : options )
432+ } ) ,
433+ queryKey : typesQueryKey ( resolveOptions ( options ) )
430434} ) ;
431435
432436export const complexTypesQueryKey = ( options : Options < ComplexTypesData > ) => createQueryKey ( 'complexTypes' , options ) ;
433437
434438export const complexTypesOptions = ( options : Options < ComplexTypesData > | typeof skipToken ) => queryOptions < ComplexTypesResponse , AxiosError < DefaultError > , ComplexTypesResponse , ReturnType < typeof complexTypesQueryKey > > ( {
435- queryFn : options === skipToken ? skipToken : async ( { queryKey, signal } ) => {
439+ queryFn : resolveQueryFn ( options , async ( { queryKey, signal } ) => {
436440 const { data } = await complexTypes ( {
437441 ...options ,
438442 ...queryKey [ 0 ] ,
439443 signal,
440444 throwOnError : true
441445 } ) ;
442446 return data ;
443- } ,
444- queryKey : complexTypesQueryKey ( options === skipToken ? undefined as never : options )
447+ } ) ,
448+ queryKey : complexTypesQueryKey ( resolveOptions ( options ) )
445449} ) ;
446450
447451export const callWithResultFromHeaderMutation = ( options ?: Partial < Options < CallWithResultFromHeaderData > > ) : MutationOptions < unknown , AxiosError < DefaultError > , Options < CallWithResultFromHeaderData > > => {
0 commit comments