Based on the documentation here, you can call another route on the server side using the const caller = route.createCaller({})
function. However, if the route is within itself, is it possible to do so using the this
keyword? If not, how can one call a route sibling?
import { z } from "zod";
import { router, publicProcedure } from "../trpc";
export const exampleRouter = router({
hi: publicProcedure.query(async () => {
return "Hi there!";
}),
world: publicProcedure.query(async () => {
return "World";
}),
hello: publicProcedure.query(async function () {
const caller = this.createCaller({});
const result = await caller.example.hi();
}),
});