Skip to content

Commit 12173dd

Browse files
committed
example: add todos to advanced example
1 parent 8e72f91 commit 12173dd

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

playgrounds/advanced/app.vue

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
<script setup lang="ts">
2+
import { useQuery } from "@tanstack/vue-query"
3+
24
const { $createHooks, $test } = useNuxtApp()
35
$test.log("hello")
6+
7+
const { data, isLoading } = useQuery({
8+
queryKey: ["todos"],
9+
queryFn: () => $fetch("/api/todos")
10+
})
411
</script>
512

613
<template>
7-
HELLO WORLD
14+
<h1>Advanced Example</h1>
815
<pre>
916
{{ typeof $createHooks }}
1017
</pre>
18+
<div>
19+
<h2>Todos</h2>
20+
<p v-if="isLoading">
21+
Loading
22+
</p>
23+
<pre>{{ data }}</pre>
24+
</div>
1125
</template>

playgrounds/advanced/nuxt.config.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ export default defineNuxtConfig({
55
// "@hebilicious/vue-query-nuxt"
66
],
77
vueQuery: {
8-
stateKey: "advanced-key",
8+
// stateKey: "advanced-key",
99
queryClientOptions: {
1010
defaultOptions: {
1111
queries: { staleTime: 1000 }
1212
}
13-
},
14-
vueQueryPluginOptions: {
15-
queryClientKey: "custom-key"
1613
}
14+
// vueQueryPluginOptions: {
15+
// queryClientKey: "custom-key"
16+
// }
1717
},
1818
devtools: {
1919
enabled: true
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default defineEventHandler(() => {
2+
// eslint-disable-next-line no-console
3+
console.log("Fetching todos ...")
4+
return [{ id: 1, todo: "Hello" }, { id: 2, todo: "World" }]
5+
})
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createHooks } from "@wundergraph/vue-query"
22

3-
export default defineVueQueryPluginCallback(() => {
3+
export default defineVueQueryPluginCallback(async ({ queryClient }) => {
4+
queryClient.setQueryData(["todos"], [{ id: 1, todo: "Hello" }, { id: 2, todo: "World" }])
45
return { provide: { createHooks, test: console } }
56
})

0 commit comments

Comments
 (0)