Skip to content

Commit

Permalink
fix: rename infinite key in query key to _infinite
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Aug 17, 2024
1 parent 34f216f commit 16f8956
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-carrots-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': patch
---

fix: rename infinite key in query key to \_infinite
19 changes: 9 additions & 10 deletions packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => {
]),
});

const infiniteIdentifier = compiler.identifier({ text: 'infinite' });

Check warning on line 81 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L80-L81

Added lines #L80 - L81 were not covered by tests
const fn = compiler.constVariable({
expression: compiler.arrowFunction({
multiLine: true,
Expand Down Expand Up @@ -119,16 +121,16 @@ const createQueryKeyFunction = ({ file }: { file: Files[keyof Files] }) => {
typeName: returnType,
}),
compiler.ifStatement({
expression: compiler.identifier({ text: 'infinite' }),
expression: infiniteIdentifier,

Check warning on line 124 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L124

Added line #L124 was not covered by tests
thenStatement: ts.factory.createBlock(
[
compiler.expressionToStatement({
expression: compiler.binaryExpression({
left: compiler.propertyAccessExpression({
expression: 'params',
name: 'infinite',
name: '_infinite',

Check warning on line 131 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L131

Added line #L131 was not covered by tests
}),
right: compiler.identifier({ text: 'infinite' }),
right: infiniteIdentifier,

Check warning on line 133 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L133

Added line #L133 was not covered by tests
}),
}),
],
Expand Down Expand Up @@ -261,7 +263,7 @@ const createQueryKeyType = ({ file }: { file: Files[keyof Files] }) => {
},
{
isRequired: false,
name: 'infinite',
name: '_infinite',

Check warning on line 266 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L266

Added line #L266 was not covered by tests
type: compiler.keywordTypeNode({
keyword: 'boolean',
}),
Expand Down Expand Up @@ -795,6 +797,9 @@ export const handler: PluginDefinition['handler'] = ({
{
spread: 'options',
},
{
spread: 'queryKey[0]',
},

Check warning on line 802 in packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts#L800-L802

Added lines #L800 - L802 were not covered by tests
{
key: 'body',
value: compiler.objectExpression({
Expand Down Expand Up @@ -853,12 +858,6 @@ export const handler: PluginDefinition['handler'] = ({
],
}),
},
{
key: getClientBaseUrlKey(),
value: compiler.identifier({
text: `client.getConfig().${getClientBaseUrlKey()}`,
}),
},
{
key: 'throwOnError',
value: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios';
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down Expand Up @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
};
const { data } = await callWithParameters({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -253,7 +254,6 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -323,6 +323,7 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
};
const { data } = await getCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -339,7 +340,6 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -375,6 +375,7 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
};
const { data } = await postCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -391,7 +392,6 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arra
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios';
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down Expand Up @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
};
const { data } = await callWithParameters({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -253,7 +254,6 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -323,6 +323,7 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
};
const { data } = await getCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -339,7 +340,6 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -375,6 +375,7 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
};
const { data } = await postCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -391,7 +392,6 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arra
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios';
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down Expand Up @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
};
const { data } = await callWithParameters({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -253,7 +254,6 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -323,6 +323,7 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
};
const { data } = await getCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -339,7 +340,6 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -375,6 +375,7 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
};
const { data } = await postCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -391,7 +392,6 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arra
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import type { AxiosError } from 'axios';
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down Expand Up @@ -237,6 +237,7 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
};
const { data } = await callWithParameters({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -253,7 +254,6 @@ export const callWithParametersInfiniteOptions = (options: Options<CallWithParam
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -323,6 +323,7 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
};
const { data } = await getCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -339,7 +340,6 @@ export const getCallWithOptionalParamInfiniteOptions = (options: Options<GetCall
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down Expand Up @@ -375,6 +375,7 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
};
const { data } = await postCallWithOptionalParam({
...options,
...queryKey[0],
body: {
...queryKey[0].body as any,
...page.body as any
Expand All @@ -391,7 +392,6 @@ export const postCallWithOptionalParamInfiniteOptions = (options: Options<PostCa
...queryKey[0].query,
...page.query
},
baseURL: client.getConfig().baseURL,
throwOnError: true
});
return data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { client, parentModelWithDates, modelWithDates, modelWithDatesArray, arra
type QueryKey<TOptions extends Options> = [
Pick<TOptions, 'baseURL' | 'body' | 'headers' | 'path' | 'query'> & {
_id: string;
infinite?: boolean;
_infinite?: boolean;
}
];

const createQueryKey = <TOptions extends Options>(id: string, options?: TOptions, infinite?: boolean): QueryKey<TOptions>[0] => {
const params: QueryKey<TOptions>[0] = { _id: id, baseURL: client.getConfig().baseURL } as QueryKey<TOptions>[0];
if (infinite) {
params.infinite = infinite;
params._infinite = infinite;
}
if (options?.body) {
params.body = options.body;
Expand Down
Loading

0 comments on commit 16f8956

Please sign in to comment.