rustclan
rustclan2y ago

Calling a trpc endpoint inside of a trpc endpoint

Hey all. I'm wondering how I am able to call these endpoints from within themselves? For example, I'd like to call getBotGuilds and getUserGuilds from within getAllGuilds.
export const guildRouter = createTRPCRouter({
getBotGuilds: protectedProcedure.query(({ ctx }) => {
}),
getUserGuilds: protectedProcedure.query(({ ctx }) => {

return [];
}),
getAllGuilds: protectedProcedure.query(({ ctx }) => {

}),
});
export const guildRouter = createTRPCRouter({
getBotGuilds: protectedProcedure.query(({ ctx }) => {
}),
getUserGuilds: protectedProcedure.query(({ ctx }) => {

return [];
}),
getAllGuilds: protectedProcedure.query(({ ctx }) => {

}),
});
5 Replies
Alex / KATT 🐱
@cje did a video on this but I'm not on my laptop to find it Tldr don't do it
rustclan
rustclanOP2y ago
Oh.. okay. If not this, how else?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Alex / KATT 🐱
Christopher Ehrlich
YouTube
Advanced tRPC - Callers, functions, and gSSP
Repo for this video: https://github.com/c-ehrlich/you-dont-need-callers If you want to use schema in the frontend, they cannot be imported from the same file as things that run specifically in the backend. One solution would be to put them into a procedureName.schema.ts or similar file. tRPC: https://trpc.io/docs Create T3 App: https://crea...
rustclan
rustclanOP2y ago
Thanks for the responses guys. 🙂

Did you find this page helpful?