#Can't find Prisma.{Model}GetPayload
4 messages · Page 1 of 1 (latest)
The Prisma.{Model}GetPayload type is generated automatically by Prisma Client for each model in your schema, but it is not exported as a top-level type. Instead, you access it via the Prisma namespace, e.g., Prisma.UserGetPayload, Prisma.PostGetPayload, etc. If you can't find these types, make sure you have run npx prisma generate after updating your schema, and that you are importing from @prisma/client.
By default, the generated model types (e.g., User) only include scalar fields, not relations. To get a type that includes relationships, use the GetPayload type with the appropriate include or select options. For example:
import { Prisma } from '@prisma/client'
const userWithPosts = Prisma.validator<Prisma.UserDefaultArgs>()({
include: { posts: true },
})
type UserWithPosts = Prisma.UserGetPayload<typeof userWithPosts>
This will give you a type with both the scalar fields and the related posts. This approach is recommended for type safety and to avoid manual maintenance of types when your schema changes. If you still can't find the GetPayload types, ensure your Prisma Client is up to date and properly generated. More details and examples can be found in the official docs and discussions:
- Operating against partial structures of your model types
- Generated prisma types are missing relationships in their exported type
- Include relation in entity generated type
If you follow these steps and still don't see the types, there may be an issue with your Prisma setup or version.
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Hey!
Could you share a minimal example on how you are trying to import models and how you have instantiated Prisma Client?