T
tRPC

Cannot read properties of undefined (reading 'query')

Cannot read properties of undefined (reading 'query')

PPatrickJ10/22/2022
Hey folks, Updating from v9 to v10. I thought I'm done, no type errors. Launching the app in dev mode via ts-node-dev and getting this. Any idea what is going on here?
PPatrickJ10/22/2022
This also happens after building app and running it with just node
UUUnknown User10/23/2022
Message Not Public
Sign In & Join Server To View
PPatrickJ10/23/2022
@FrostyGhostMan yep
"@tanstack/react-query": "4.13.0",
"@trpc/client": "10.0.0-proxy-beta.25",
"@trpc/react-query": "10.0.0-proxy-beta.25",
"@trpc/server": "10.0.0-proxy-beta.25",
"@tanstack/react-query": "4.13.0",
"@trpc/client": "10.0.0-proxy-beta.25",
"@trpc/react-query": "10.0.0-proxy-beta.25",
"@trpc/server": "10.0.0-proxy-beta.25",
running tsc --noEmit doesn't return any issues, this is happening on the runtime
UUUnknown User10/23/2022
2 Messages Not Public
Sign In & Join Server To View
PPatrickJ10/23/2022
Nope i don't Removing node_modules and reinstalling did not help I'm still on React 17 but I believe 18 is not a must? I'm using Express for server and bundling my app with Vite I suspect it has something to do with either my procedures or the mergeRouters function
UUUnknown User10/23/2022
Message Not Public
Sign In & Join Server To View
PPatrickJ10/23/2022
No worries. Just writing here so others can see too. Thank you for your time So I managed to find the source of the problem: It happens only when I import router from another file. If I take that router code and paste to my main trpc.ts file, it works just fine. My tsconfig looks like that:
{
"compilerOptions": {
"outDir": "../../dist/api",
"module": "commonjs",
"noEmit": false,
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"types": ["vitest/globals"]
},
"include": ["**/*.ts"]
}
{
"compilerOptions": {
"outDir": "../../dist/api",
"module": "commonjs",
"noEmit": false,
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"types": ["vitest/globals"]
},
"include": ["**/*.ts"]
}
UUUnknown User10/23/2022
Message Not Public
Sign In & Join Server To View
PPatrickJ10/24/2022
I use yarn. Nothing really changes after removing that statemat
Jjulius10/24/2022
Did you go down the interop path or the codemod?
PPatrickJ10/24/2022
@julius Codemod did not work for me for some reason. I went with manual update
AKAlex / KATT 🐱10/24/2022
can you share more info? how did you setup the client? where is this called? we can't help you debug on this alone
PPatrickJ10/25/2022
Hey @alex / KATT I crated reproduction here: https://github.com/patryk-smc/trpc-10-repro
AKAlex / KATT 🐱10/25/2022
Not cloned it, just looked at my mobile, but my guess would be the circular dependencies between the trpc file and the routers? Make sure to not import anything in your trpc.ts apart from the trpc library stuff This is not how the examples are made up so unsure what happens exactly in the order of execution of those files
PPatrickJ10/25/2022
Thank you! I don't fully get this issue but I broke down my trpc file to separate the router and separate middleware file and it worked!

Looking for more? Join the community!

T
tRPC

Cannot read properties of undefined (reading 'query')

Join Server
Recommended Posts
Updating from v9 to v10 - how to access react hooks?Hey folks, I'm updating to v10. I replaced @trpc/react@9.27.4 with @trpc/react-query@10.0.0-proxy-beHow to infer the output of a mutation? The current methods appear to be depreciated.I am attempting to export the bellow utility function to use client side to infer an output type thaTrouble inferring the type of a very simple structure of nested routersA very simple router results in an inference error, causing the client to not be able to infer the rcalling trpc endpoints from vanilla nextJs api routesI'm struggling to find what's the best way to call a trpc endpoint directly from the server. BasicalMutation type issueI'm trying to mutate something like this with tRPC and Prisma ```const updateColumn = trpc.project.uCan I redirect the user from inside my router?I have a query protectedProcedure, which returns an object from my prisma planetscale db What's theInfer the type of ctx for a specific procedureLet's say I had a helper function that I wanted to pass the context to, I can't use the default ContCORS in standalone serverHi, I'm trying to get CORS working in standalone server. Attempted this solution but unfortunatelyQueries break when in production on Vercel; work on localhostThe query is called like this: ```javascript const { data } = api.useQuery(["user.!getCount"], { Can't get client to workHi, I can't get my client to work I'm using Next.js but I have also tried the React method from the Request context inside middleware?Hi, Is it possible to get the request context inside a middleware somehow? I'm trying to migrate data becomes never[] when destructuring with a fallback valueCurrently it doesn't seem possible to set a fallback value on a destructured `data` property, for exSyntaxError Unexpected token u in JSON at position 0 with mutationsI'm trying to use trpc client to await a mutation and just keep getting this error. everything worksLosing the type between the client and serverHello everyone, I am new to tRPC and the magic of types in typescript so I am looking for ideas as tMobile app with tRPCWhat's the suggested way of working with tRPC when it comes to mobile apps? How do you ensure that yHow to use trpc react hooks from an external data sourceHi, I have a monorepo, nextjs and keystone cms. The cms has trpc running, and I managed to get it coNextJS & Keystone CMS, issues when connecting both in a monorepoHello everyone, so I have a monorepo with NextJS and keystone cms, both are running trpc v10beta.15Best practices for implementing an offline applicationHey there! I'm building a full stack react-native app with Expo and a tRPC backend. I'd like for thisomehow when move typed function out of the router files, frontend infer type to be any ?this is inferred corrected since they are in the same file. ``` getX: t.procedure.query(() => { retBig companies that use tRPC?Some of my fellow colleagues were wondering if there are any big companies that use tRPC and how mat