trpc v11 error: The transformer property has moved to httpLink/httpBatchLink/wsLink
Just upgraded tRPC to v11 and I directly got this error: Type typeof SuperJSON is not assignable to type
TypeError<"The transformer property has moved to httpLink/httpBatchLink/wsLink">
Type typeof SuperJSON is not assignable to type
"The transformer property has moved to httpLink/httpBatchLink/wsLink"
My client initialization of tRPC:
Solution:Jump to solution
Basically, turn this
```ts
export const api = createTRPCNext<AppRouter>({
config() {...
9 Replies
Temporarily you're able to remove transformer property from the object you're returning. tRPC docs say that you should only specify a transformer in their httpBatchLink(). Thus, that approach will work out, it will make TS yell at you due to the type mismatch. That should at least help you move forward until TS wizard comes here and magically fixes types on initTRPC
Hi, yes, I figured out thst I have to love the transformer out of the object thst im returning down to below the ssr stuff.
I've had a similar issue - also upgraded to v11. when i leave the transformer as it is, everything works fine (i do get a TS error but can ignore it and still build/deploy); when I try moving the transformer into httpBatchLink as suggested, the public procedures work fine but the private ones don't (i get the code:'UNAUTHORISED' error; with the transformer moved into httpBatchLink, ctx.session is now null in the privateProcedure which would explain why this is happening). any ideas?
(same for httpLink by the way)
ok it's something to do with the cookies not being passed. if I console log out ctx.headers in the working old version i can see all the relevant stuff being passed (next-auth.csrf-token, session, user etc). moving transform to httpBatchLink it is just generic headers with no session/user/nextauth info
You shouldn't get typeErrs, unless you've entirely got rid of transformer.
The idea was to move it out from it's inital wrapping object
Solution
Basically, turn this
into this
Unless you've done your type of ts magic underneath the hood, that should work out just fine even while using private procedures
yeah honestly am just using the default t3 setup -
transformer is just from the shared.ts
That seems like a strange behaviour, though I'm not that familiar with RSC version of T3 yet, to help out. All I can suggest is to debug the ctx everywhere starting from observable callback
ty, that was my thought too, will give it a go. this is all because i've got another package that i absolutely can't do without that needs react-query ^5 (trpc 10 needs ^4 i believe)