Closed KATT closed 2 years ago
I love this
It looks so good! I only have two minor questions:
mergeRouters
accept prefix
like it does now, likeexport const appRouter = trpc.mergeRouters({
post: postRouter
}, health);
concat
mutliple input
s? For example maybe I have another isPartOfTeam
input + middleware, and I want to use it with isPartOfOrg
? If yes, will the order of input
and use
affect the actual validation? Say in procedure.input(a).use(b).input(c).resolve(d)
, both b
and c
will fail, what error would be returned?
I've let this marinate, and I think chaining for the resolver API could be nicer. I've here created a POC that you can compare side-by-side with the
main
branch. Closes #25 & Closes #24.Notes
throw Error
below; imaginethrow TRPCError({ code: '..'})
input
before or after your middlewares run, it's up to you!§1 Basics
§1.0 Setting up tRPC
§1.1 Creating a router
§1.2 Defining a procedure
Details about the procedure builder
Simplified to be more readable - see full implementation in https://github.com/trpc/v10-playground/blob/katt/procedure-chains/src/trpc/server/procedure.ts
§1.3 Adding input parser
§1.4 Procedure with middleware
§2 Intermediate 🍿
§2.1 Define a reusable middleware
§2.2 Create a bunch of procedures that are all protected
§2.3 Define an
output
schema§2.4 Merging routers
§3 Advanced 🧙
Compose dynamic combos of middlewares/input parsers