How do you get defined types for relational queries
If i have a relational query like this
How do i get the type of
post
as a defined type to use as a function parameter type for instance?
in prisma land, i manually have to define types like
is there a better way to do this?5 Replies
type PostWithComments = typeof post;
can work
inference can be used in many placeshow would that include
comments
as a field? in theory, there should be 2 different types
i’m not sure if this would work but you could do something like this possibly
this might be what you’re looking for if you don’t want to create the type yourself
@jakeleventhal
In his case it would actually be something like that:
By inferring the return type for the query
It would also be updated with your schema, contrary to what the example above does
But you'd have to export this type from below the query
Do what's better for you
yeah so at the end of the day, you still have to manually define your types