Skip to content

Commit

Permalink
fix: 914
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim-Mazurok committed Oct 9, 2023
1 parent 6256d76 commit 234cb61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
jsDoc,
GetterQueryParam,
compareVersions,
getRouteAsArray,
} from '@orval/core';
import omitBy from 'lodash.omitby';
import {
Expand Down Expand Up @@ -1128,7 +1129,9 @@ const generateQueryHook = async (
'implementation',
);

const routeString = `\`${route}\``;
const routeString = isVue(outputClient)
? getRouteAsArray(route) // Note: this is required for reactivity to work, we will lose it if route params are converted into string, only as array they will be tracked // TODO: add tests for this
: `\`${route}\``;

// Note: do not unref() params in Vue - this will make key lose reactivity
const queryKeyFn = `export const ${queryKeyFnName} = (${queryKeyProps}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getListPetsQueryKey = (
params?: MaybeRef<ListPetsParams>,
version = 1,
) => {
return [`/v${version}/pets`, ...(params ? [params] : [])] as const;
return ['v', version, 'pets', ...(params ? [params] : [])] as const;
};

export const getListPetsInfiniteQueryOptions = <
Expand Down Expand Up @@ -284,7 +284,7 @@ export const getShowPetByIdQueryKey = (
petId: MaybeRef<string>,
version = 1,
) => {
return [`/v${version}/pets/${petId}`] as const;
return ['v', version, 'pets', petId] as const;
};

export const getShowPetByIdInfiniteQueryOptions = <
Expand Down

0 comments on commit 234cb61

Please sign in to comment.