-
When trying to compose a findMany with a relation i noticed that that the types inferred are incorrect.
I know this example is quite contrived, but there are use cases. I would have thought that the types would have been inferred up to getPostsWithComments, is there something i am missing? |
Beta Was this translation helpful? Give feedback.
Answered by
ryands17
May 4, 2020
Replies: 1 comment 2 replies
-
Hey @JClackett 👋 model User {
id Int @default(autoincrement()) @id
email String @unique
password String
name String?
posts Post[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Post {
id String @default(cuid()) @id
published Boolean
title String
content String?
author User? @relation(fields: [authorId], references: [id])
authorId Int?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
} and on running this query, I get the following type const user = await prisma.user.findMany({
include: {
posts: true,
},
}) const user: (Prisma.User & {
posts: Prisma.Post[];
})[] So the type system should be working correctly. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
JClackett
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @JClackett 👋
I have create the same with the following schema
and on running this query, I get the following type