You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the base procedures pattern with merged input, trpc panel throws the following error:
trpc-panel: Failed to parse procedure <procedure-name>, Couldn't parse node.
When we get this error, the procedure does not show on the panel UI at all.
More Context
tRPC allows us to use base procedures to reuse procedure code and prevent repetition. One feature of base procedures--that is not clearly shown in the documentation example--is input schema merging: if a procedure declares its own (zod) schema and "extends" a base procedure that also declares its own input schema, tRPC merges those input schemas into one.
For example:
// base procedureconstadminProcedure=t.procedure.input(z.object({adminId: z.string().cuid()})).use((opts)=>{if(!opts.input.adminId){thrownewTRPCError({code: 'UNAUTHORIZED',message: "No admin ID provided",})}returnopts.next()})exportconstappRouter=t.router({banUser: adminProcedure.input(z.object({userId: z.string().cuid()})).mutation(()=>{
...
}),})
The procedure banUser "extends" the base adminProcedure. tRPC will resolve the input required for banUser by merging the two declared inputs, requiring both adminId and userId.
The text was updated successfully, but these errors were encountered:
The problem
When using the base procedures pattern with merged input, trpc panel throws the following error:
When we get this error, the procedure does not show on the panel UI at all.
More Context
tRPC allows us to use base procedures to reuse procedure code and prevent repetition. One feature of base procedures--that is not clearly shown in the documentation example--is input schema merging: if a procedure declares its own (zod) schema and "extends" a base procedure that also declares its own input schema, tRPC merges those input schemas into one.
For example:
The procedure
banUser
"extends" the baseadminProcedure
. tRPC will resolve the input required forbanUser
by merging the two declared inputs, requiring bothadminId
anduserId
.The text was updated successfully, but these errors were encountered: