#Can i import types from query-outputs like trpc's RouterOutputs.
3 messages · Page 1 of 1 (latest)
Hi @visual bay. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, you can import types from query outputs in Convex. However, the exact method may vary depending on the specific setup of your project. For instance, in a tRPC project, you can provide a Zod object to .input to validate your endpoint’s arguments. Here's an example:
const t = initTRPC.create();
const appRouter = t.router({
greeting: t.publicProcedure
.input(z.object({ name: z.string() }))
.query((opts) => {
const { input } = opts;
return `Hello ${input.name}`;
}),
});
In this example, the type of input is inferred from the Zod schema provided to .input.
For more specific guidance on importing types in Convex, you may want to refer to the Convex documentation (https://docs.convex.dev/) or ask in the Convex community channels.