What's the right way to get the type of a query?
Hi, I have this
and I'm trying to get the type of the ticket that is given back, which has a few additional types due to the "with" statements. Main reason for this is I want to have a function that cleans the response up before i send it back to the frontend and then i also want to be able to get these types over to my frontend repo.
What's the best way to get the type of this query?
3 Replies
There is a PR to implement a helper like this in drizzle
But here is a workaround for you https://github.com/drizzle-team/drizzle-orm/issues/695#issuecomment-1881454650
GitHub
Implement infering table model with relations · Issue #695 · drizzl...
Prisma API: import { Prisma } from '@prisma/client' // 1: Define a type that includes the relation to
Post
const userWithPosts = Prisma.validator<Prisma.UserDefaultArgs>()({ include...Thanks! This seems to work.
I also think that documentation around this (and any other type extraction) is important - the main reason I'm using Drizzle is for type safety and migrations