-
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.
Replies: 2 comments 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.
-
Hi @JClackett, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that have already been marked as answered but remain open. If this discussion still requires further input or clarification, feel free to reopen it or start a new one with updated details. Your contributions are invaluable to the community, and we’re here to help! For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and ongoing support of the Prisma community! |
Beta Was this translation helpful? Give feedback.
Hey @JClackett 👋
I have create the same with the following schema
and on running this query, I get the following type