_braden
_braden15mo ago

Router/Middleware Chaining in V10

Heyo, finally migrating from v9 to v10 after putting it off for a while. Is it just me, or is this migration pretty rough? Really enormous amount of changes and not really a way to do it incrementally. I found interop() didn't work at all, and still not sure if it's going to run after everything. Anyways, in v9, I used router/middleware chaining to establish secure namespaces. That is, every query within, for example, 'A.B.C.', is using middleware established in B. It seems like in v10, middleware has been moved from the router layer to the procedure layer. Do I need to manually rewrite every function in my routers to use this new paradigm, or is there an equivalent?
1 Reply
_braden
_bradenOP15mo ago
I think found an answer in the form of this Github Discussion. https://github.com/trpc/trpc/discussions/2221 This is... pretty rough. :/ I guess I'll just keep using v9. Not being able to apply middleware to entire namespaces is a huge miss, imo. Will result in a very painful migration, a lot of duplicate code, and weird middleware piping scenarios for my project.
GitHub
tRPC v10 middleware implementation · trpc trpc · Discussion #2221
In tRPC 9, we get the ability to apply middleware to every query/mutation in a router as a result of chaining queries/mutations. However it seems like in v10 we'd have to individually apply cer...