Skip to content

Commit f242e0b

Browse files
committed
fix(vue-query-app): update sample
1 parent 728f915 commit f242e0b

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

samples/vue-query/orval.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export default defineConfig({
99
schemas: 'src/api/model',
1010
client: 'vue-query',
1111
mock: true,
12+
prettier: true,
1213
override: {
1314
mutator: {
1415
path: './src/api/mutator/custom-instance.ts',

samples/vue-query/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@vue/compiler-sfc": "3.2.36",
1919
"msw": "^0.32.0",
2020
"orval": "link:../../packages/orval/dist",
21+
"prettier": "^3.0.3",
2122
"typescript": "^4.3.2",
2223
"vite": "^2.4.2",
2324
"vue-tsc": "^0.0.24"

samples/vue-query/src/App.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<img src="./assets/logo.svg" class="App-logo" alt="logo" />
55
<Pet
66
v-if="selectedPetId"
7+
:key="selectedPetId"
78
:pet-id="selectedPetId"
89
:id="'selected-pet-' + selectedPetId"
910
/>

samples/vue-query/src/api/endpoints/petstoreFromFileSpecWithTransformer.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ export const listPets = (
3838
version = 1,
3939
signal?: AbortSignal,
4040
) => {
41+
params = unref(params);
42+
version = unref(version);
43+
4144
return customInstance<Pets>({
42-
url: `/v${unref(version)}/pets`,
45+
url: `/v${version}/pets`,
4346
method: 'get',
4447
params,
4548
signal,
@@ -49,7 +52,11 @@ export const listPets = (
4952
export const getListPetsQueryKey = (
5053
params?: MaybeRef<ListPetsParams>,
5154
version = 1,
52-
) => ['v', version, 'pets', ...(params ? [params] : [])] as const;
55+
) => {
56+
params = unref(params);
57+
version = unref(version);
58+
return [`/v${version}/pets`, ...(params ? [params] : [])] as const;
59+
};
5360

5461
export const getListPetsInfiniteQueryOptions = <
5562
TData = Awaited<ReturnType<typeof listPets>>,
@@ -184,8 +191,11 @@ export const createPets = (
184191
createPetsBody: MaybeRef<CreatePetsBody>,
185192
version = 1,
186193
) => {
194+
createPetsBody = unref(createPetsBody);
195+
version = unref(version);
196+
187197
return customInstance<Pet>({
188-
url: `/v${unref(version)}/pets`,
198+
url: `/v${version}/pets`,
189199
method: 'post',
190200
headers: { 'Content-Type': 'application/json' },
191201
data: createPetsBody,
@@ -252,15 +262,24 @@ export const showPetById = (
252262
version = 1,
253263
signal?: AbortSignal,
254264
) => {
265+
petId = unref(petId);
266+
version = unref(version);
267+
255268
return customInstance<Pet>({
256-
url: `/v${unref(version)}/pets/${unref(petId)}`,
269+
url: `/v${version}/pets/${petId}`,
257270
method: 'get',
258271
signal,
259272
});
260273
};
261274

262-
export const getShowPetByIdQueryKey = (petId: MaybeRef<string>, version = 1) =>
263-
['v', version, 'pets', petId] as const;
275+
export const getShowPetByIdQueryKey = (
276+
petId: MaybeRef<string>,
277+
version = 1,
278+
) => {
279+
petId = unref(petId);
280+
version = unref(version);
281+
return [`/v${version}/pets/${petId}`] as const;
282+
};
264283

265284
export const getShowPetByIdInfiniteQueryOptions = <
266285
TData = Awaited<ReturnType<typeof showPetById>>,

samples/vue-query/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,11 @@ postcss@^8.1.10, postcss@^8.3.5:
835835
nanoid "^3.1.23"
836836
source-map-js "^0.6.2"
837837

838+
prettier@^3.0.3:
839+
version "3.0.3"
840+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643"
841+
integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==
842+
838843
process-nextick-args@~2.0.0:
839844
version "2.0.1"
840845
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"

0 commit comments

Comments
 (0)