diff --git a/playground/pages/index.vue b/playground/pages/index.vue
index abdede6..451bedf 100644
--- a/playground/pages/index.vue
+++ b/playground/pages/index.vue
@@ -1,5 +1,23 @@
@@ -17,6 +35,9 @@ const { data: todos, pending, error, refresh } = await useAsyncQuery(['getTodos'
+
diff --git a/playground/server/trpc/index.ts b/playground/server/trpc/index.ts
index 3119beb..5e01569 100644
--- a/playground/server/trpc/index.ts
+++ b/playground/server/trpc/index.ts
@@ -1,15 +1,17 @@
import * as trpc from '@trpc/server'
import { z } from 'zod'
-export interface Todo {
- userId: number
- id: number
- title: string
- completed: boolean
-}
-
const baseURL = 'https://jsonplaceholder.typicode.com'
+const TodoShape = z.object({
+ userId: z.number(),
+ id: z.number(),
+ title: z.string(),
+ completed: z.boolean(),
+})
+
+export type Todo = z.infer
+
export const router = trpc.router()
.query('getTodos', {
async resolve() {
@@ -22,3 +24,12 @@ export const router = trpc.router()
return await $fetch(`${baseURL}/todos/${req.input}`)
},
})
+ .mutation('addTodo', {
+ input: TodoShape,
+ async resolve(req) {
+ return await $fetch(`${baseURL}/todos`, {
+ method: 'POST',
+ body: req.input,
+ })
+ },
+ })