Skip to content

Commit 98559ea

Browse files
committed
fix: make options optional in setQueryData/useSetQueryData when operation has no required params
1 parent 7bac213 commit 98559ea

8 files changed

Lines changed: 74 additions & 62 deletions

File tree

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/setQueryData/@tanstack/react-query.gen.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTag
5454
queryKey: serviceWithEmptyTagQueryKey(options)
5555
});
5656

57-
export const serviceWithEmptyTagSetQueryData = (queryClient: QueryClient, options: Options<ServiceWithEmptyTagData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
57+
export const serviceWithEmptyTagSetQueryData = (queryClient: QueryClient, options?: Options<ServiceWithEmptyTagData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
5858

5959
export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => {
6060
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> = {
@@ -113,7 +113,7 @@ export const getCallWithoutParametersAndResponseOptions = (options?: Options<Get
113113
queryKey: getCallWithoutParametersAndResponseQueryKey(options)
114114
});
115115

116-
export const getCallWithoutParametersAndResponseSetQueryData = (queryClient: QueryClient, options: Options<GetCallWithoutParametersAndResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
116+
export const getCallWithoutParametersAndResponseSetQueryData = (queryClient: QueryClient, options?: Options<GetCallWithoutParametersAndResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
117117

118118
export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => {
119119
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> = {
@@ -273,7 +273,7 @@ export const duplicateName2Options = (options?: Options<DuplicateName2Data>) =>
273273
queryKey: duplicateName2QueryKey(options)
274274
});
275275

276-
export const duplicateName2SetQueryData = (queryClient: QueryClient, options: Options<DuplicateName2Data>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
276+
export const duplicateName2SetQueryData = (queryClient: QueryClient, options?: Options<DuplicateName2Data>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
277277

278278
export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => {
279279
const mutationOptions: UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> = {
@@ -318,7 +318,7 @@ export const callWithNoContentResponseOptions = (options?: Options<CallWithNoCon
318318
queryKey: callWithNoContentResponseQueryKey(options)
319319
});
320320

321-
export const callWithNoContentResponseSetQueryData = (queryClient: QueryClient, options: Options<CallWithNoContentResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
321+
export const callWithNoContentResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithNoContentResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
322322

323323
export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options);
324324

@@ -335,7 +335,7 @@ export const callWithResponseAndNoContentResponseOptions = (options?: Options<Ca
335335
queryKey: callWithResponseAndNoContentResponseQueryKey(options)
336336
});
337337

338-
export const callWithResponseAndNoContentResponseSetQueryData = (queryClient: QueryClient, options: Options<CallWithResponseAndNoContentResponseData>, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
338+
export const callWithResponseAndNoContentResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithResponseAndNoContentResponseData>, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
339339

340340
export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options);
341341

@@ -352,7 +352,7 @@ export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<unk
352352
queryKey: dummyAQueryKey(options)
353353
});
354354

355-
export const dummyASetQueryData = (queryClient: QueryClient, options: Options<DummyAData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
355+
export const dummyASetQueryData = (queryClient: QueryClient, options?: Options<DummyAData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
356356

357357
export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options);
358358

@@ -369,7 +369,7 @@ export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<unk
369369
queryKey: dummyBQueryKey(options)
370370
});
371371

372-
export const dummyBSetQueryData = (queryClient: QueryClient, options: Options<DummyBData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
372+
export const dummyBSetQueryData = (queryClient: QueryClient, options?: Options<DummyBData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
373373

374374
export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options);
375375

@@ -386,7 +386,7 @@ export const callWithResponseOptions = (options?: Options<CallWithResponseData>)
386386
queryKey: callWithResponseQueryKey(options)
387387
});
388388

389-
export const callWithResponseSetQueryData = (queryClient: QueryClient, options: Options<CallWithResponseData>, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
389+
export const callWithResponseSetQueryData = (queryClient: QueryClient, options?: Options<CallWithResponseData>, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
390390

391391
export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => {
392392
const mutationOptions: UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> = {

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/useSetQueryData/@tanstack/react-query.gen.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const serviceWithEmptyTagOptions = (options?: Options<ServiceWithEmptyTag
5656

5757
export const useServiceWithEmptyTagSetQueryData = () => {
5858
const queryClient = useQueryClient();
59-
return (options: Options<ServiceWithEmptyTagData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
59+
return (options?: Options<ServiceWithEmptyTagData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(serviceWithEmptyTagOptions(options).queryKey, updater);
6060
};
6161

6262
export const patchApiVbyApiVersionNoTagMutation = (options?: Partial<Options<PatchApiVbyApiVersionNoTagData>>): UseMutationOptions<unknown, DefaultError, Options<PatchApiVbyApiVersionNoTagData>> => {
@@ -118,7 +118,7 @@ export const getCallWithoutParametersAndResponseOptions = (options?: Options<Get
118118

119119
export const useGetCallWithoutParametersAndResponseSetQueryData = () => {
120120
const queryClient = useQueryClient();
121-
return (options: Options<GetCallWithoutParametersAndResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
121+
return (options?: Options<GetCallWithoutParametersAndResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(getCallWithoutParametersAndResponseOptions(options).queryKey, updater);
122122
};
123123

124124
export const patchCallWithoutParametersAndResponseMutation = (options?: Partial<Options<PatchCallWithoutParametersAndResponseData>>): UseMutationOptions<unknown, DefaultError, Options<PatchCallWithoutParametersAndResponseData>> => {
@@ -284,7 +284,7 @@ export const duplicateName2Options = (options?: Options<DuplicateName2Data>) =>
284284

285285
export const useDuplicateName2SetQueryData = () => {
286286
const queryClient = useQueryClient();
287-
return (options: Options<DuplicateName2Data>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
287+
return (options?: Options<DuplicateName2Data>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(duplicateName2Options(options).queryKey, updater);
288288
};
289289

290290
export const duplicateName3Mutation = (options?: Partial<Options<DuplicateName3Data>>): UseMutationOptions<unknown, DefaultError, Options<DuplicateName3Data>> => {
@@ -332,7 +332,7 @@ export const callWithNoContentResponseOptions = (options?: Options<CallWithNoCon
332332

333333
export const useCallWithNoContentResponseSetQueryData = () => {
334334
const queryClient = useQueryClient();
335-
return (options: Options<CallWithNoContentResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
335+
return (options?: Options<CallWithNoContentResponseData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(callWithNoContentResponseOptions(options).queryKey, updater);
336336
};
337337

338338
export const callWithResponseAndNoContentResponseQueryKey = (options?: Options<CallWithResponseAndNoContentResponseData>) => createQueryKey('callWithResponseAndNoContentResponse', options);
@@ -352,7 +352,7 @@ export const callWithResponseAndNoContentResponseOptions = (options?: Options<Ca
352352

353353
export const useCallWithResponseAndNoContentResponseSetQueryData = () => {
354354
const queryClient = useQueryClient();
355-
return (options: Options<CallWithResponseAndNoContentResponseData>, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
355+
return (options?: Options<CallWithResponseAndNoContentResponseData>, updater: CallWithResponseAndNoContentResponseResponse | undefined | ((old: CallWithResponseAndNoContentResponseResponse | undefined) => CallWithResponseAndNoContentResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseAndNoContentResponseOptions(options).queryKey, updater);
356356
};
357357

358358
export const dummyAQueryKey = (options?: Options<DummyAData>) => createQueryKey('dummyA', options);
@@ -372,7 +372,7 @@ export const dummyAOptions = (options?: Options<DummyAData>) => queryOptions<unk
372372

373373
export const useDummyASetQueryData = () => {
374374
const queryClient = useQueryClient();
375-
return (options: Options<DummyAData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
375+
return (options?: Options<DummyAData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyAOptions(options).queryKey, updater);
376376
};
377377

378378
export const dummyBQueryKey = (options?: Options<DummyBData>) => createQueryKey('dummyB', options);
@@ -392,7 +392,7 @@ export const dummyBOptions = (options?: Options<DummyBData>) => queryOptions<unk
392392

393393
export const useDummyBSetQueryData = () => {
394394
const queryClient = useQueryClient();
395-
return (options: Options<DummyBData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
395+
return (options?: Options<DummyBData>, updater: unknown | undefined | ((old: unknown | undefined) => unknown | undefined)) => queryClient.setQueryData(dummyBOptions(options).queryKey, updater);
396396
};
397397

398398
export const callWithResponseQueryKey = (options?: Options<CallWithResponseData>) => createQueryKey('callWithResponse', options);
@@ -412,7 +412,7 @@ export const callWithResponseOptions = (options?: Options<CallWithResponseData>)
412412

413413
export const useCallWithResponseSetQueryData = () => {
414414
const queryClient = useQueryClient();
415-
return (options: Options<CallWithResponseData>, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
415+
return (options?: Options<CallWithResponseData>, updater: CallWithResponseResponse | undefined | ((old: CallWithResponseResponse | undefined) => CallWithResponseResponse | undefined)) => queryClient.setQueryData(callWithResponseOptions(options).queryKey, updater);
416416
};
417417

418418
export const callWithDuplicateResponsesMutation = (options?: Partial<Options<CallWithDuplicateResponsesData>>): UseMutationOptions<CallWithDuplicateResponsesResponse, CallWithDuplicateResponsesError, Options<CallWithDuplicateResponsesData>> => {

0 commit comments

Comments
 (0)