Nested tRPC procedures.
I'm trying to convert a REST API structure to tRPC. Specifically, I want to replicate the nested REST route
products/:productId/discount
in tRPC ?
. How should I declare and organize these nested routes in tRPC to match this structure effectively?Solution:Jump to solution
there is no reason for the nesting here because you only have one procedure inside the nested routers
12 Replies
trpc.products.discount?
like should i nest a router into another ?
Solution
there is no reason for the nesting here because you only have one procedure inside the nested routers
also with trpc, there is no one set guideline, organise it the way you like basically 😅
you mean i can use
trpc.product.getDiscount
?yeah
thanks Ahmed
no worries
if you have any
trpc
best practices docs or articles please do share with me.the one I would give is, start with one router until it feels complex enough to need to split/nest it
sounds great!