v-for-v
v-for-v
TTCTheo's Typesafe Cult
Created by v-for-v on 5/4/2024 in #questions
How to get TRPC mutation type?
Does anyone know how to get the useMutation return type for a TRPC mutation? I want to pass a mutation down as props but cannot get the types working
const mutationResult = api.myRouter.createPost.useMutation() // What type is this?

// Type error
return <Child mutationResult={mutationResult} />
const mutationResult = api.myRouter.createPost.useMutation() // What type is this?

// Type error
return <Child mutationResult={mutationResult} />
2 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/21/2024 in #questions
Bug!? Server side calls are not being cached
The below is causing 2 API requests, one of the key patterns in the app router is to be able to call API functions wherever and have the response be cached across the entire request.
async function Page(){
await serverApi.user.me()

return <ServerComponent />
}

const async ServerComponent = () => {
await serverApi.user.me()

return null
}
async function Page(){
await serverApi.user.me()

return <ServerComponent />
}

const async ServerComponent = () => {
await serverApi.user.me()

return null
}
54 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/20/2024 in #questions
No example of error handling in the app router
There's no example of how to get typesafe errors using the error.jsx file
3 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/15/2024 in #questions
Will server components be refeteched on mutation?
If I have a page using the server trpc and then a client component that updates the list, will the server trpc call be refreshed?
4 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/12/2024 in #questions
No typesaftey for dynamic returns
// BE
publicProcedure.input(z.object({shouldPopulateRelation: z.boolean()})).query(({ input, ctx }) => {
return ctx.db.thing.findMany({ include: input.shouldPopulateRealtion })
})

// FE
const {data} = api.thing.useQuery({shouldPopulateRelation: false})

data.relation // exists when it shouldn't
// BE
publicProcedure.input(z.object({shouldPopulateRelation: z.boolean()})).query(({ input, ctx }) => {
return ctx.db.thing.findMany({ include: input.shouldPopulateRealtion })
})

// FE
const {data} = api.thing.useQuery({shouldPopulateRelation: false})

data.relation // exists when it shouldn't
Even more concerning is that the data.relation field isn't even optional which is surely an error
3 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/2/2024 in #questions
Turborepo without Expo?
Is there a way to get things working in a Turborepo without the expo app? I'm assuming the Expo app adds a bunch of bloat / workaround which wouldn't be needed without Expo
6 replies
TTCTheo's Typesafe Cult
Created by v-for-v on 4/1/2024 in #questions
Are cold starts an issue?
I haven't used Next API routes as a primary API before, and from what I understand they are mostly serverless functions, are there cold start issues?
4 replies