Can I call tRPC procedure inside another procedure?
Something like this:
Solution
You may need to call your procedure(s) directly from the same server they're hosted in, router.createCaller() can be used to achieve this.
export const mainRouter = createTRPCRouter({
create: privateProcedure
.mutation(async ({ ctx }) => {
...
doSomething({someInput: ""}) // call doSomething here with inputs
}),
doSomething: privateProcedure
.input(
z.object({
someInput: z.string(),
})
)
}