tRPC middleware infer type from another protectedProcedure
Hello,
protectedProcedure
check and adds a not nullable user to the ctx. However the studyMiddleware
does not know that user is not nullable, is there a way for the middleware to be aware of it?
In my current code I had to validate the user is not nullable inside the middleware and had to manually pass the user to the ctx user: opts.ctx.user,
to make user not nullable inside the mutation.
Here is a sample of my code
1 Reply
I've found using procedure works better for types than the middleware. If you change your middleware and use
.use
it should probably work as you expect!