Skip to content

Generated prisma types are missing relationships in their exported type. #10928

Answered by austincrim
dannysmc95 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @dannysmc95 👋 !

Since Prisma queries do not include relations by default (you have to use the include option), the generated types do not include them either. You can create the type you are looking for using one of our built-in utility types, though.

import { Prisma } from '@prisma/client'
type FactionWithOwner = Prisma.FactionGetPayload<{
  include: { owner: true }
}>

Here we use the FactionGetPayload type and pass in some query options as the generic parameter to get the desired type.

Let me know if you have any questions about this!

Replies: 18 comments 38 replies

Comment options

You must be logged in to vote
17 replies
@adityapadekar
Comment options

@thw0rted
Comment options

@adityapadekar
Comment options

@thw0rted
Comment options

@adityapadekar
Comment options

Answer selected by dannysmc95
Comment options

You must be logged in to vote
3 replies
@jumantet
Comment options

@JefferyHus
Comment options

@ErnestoSalazar
Comment options

Comment options

You must be logged in to vote
5 replies
@Honatas
Comment options

@gregg-cbs
Comment options

@conterio
Comment options

@thw0rted
Comment options

@swalker326
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@kilroyjones
Comment options

@ngharry
Comment options

@bursteways
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@thetminko
Comment options

Comment options

You must be logged in to vote
1 reply
@JefferyHus
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@ZeldOcarina
Comment options

Comment options

You must be logged in to vote
4 replies
@swalker326
Comment options

@ericfel93
Comment options

@thw0rted
Comment options

@ericfel93
Comment options

Comment options

You must be logged in to vote
3 replies
@wanjas
Comment options

@nawangwe
Comment options

@thw0rted
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Converted from issue

This discussion was converted from issue #10909 on January 03, 2022 12:55.