Can I call tRPC procedure inside another procedure?

Something like 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(),
      })
    )
}
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.
Server Side Calls | tRPC
Was this page helpful?