carlus
PPrisma
•Created by carlus on 10/18/2024 in #help-and-questions
Wrong types for optional fields
Hi everyone, I searched a lot about my issue but could not find a solution yet and I was hoping for some expert advice in here!
It's about generated typing of Prisma optional fields in schema. It seems that for Prisma they are always there while they could be null :thinking: , for example:
export type Booking = Prisma.BookingGetPayload<{
include: {
user: {
include: {
address: true;
};
};
};
}>;
user schema has:
addressId String? @db.Uuid
address Address? @relation(fields: [addressId], references: [id])
if I then fetch the booking and do booking.user.address the typescript won't tell me that address might not be there. Did you encounter this issue? Am I doing something wrong?
Thanks a lot in advance
1 replies