Prisma generated type missing joined schema in exported type

I am new to Prisma and trying to generate a type based on my prisma schema. The type seems to export correctly, except its missing the value that joins from another schema. For example, I have a Recipe schema with an ingredients array that references another schema, and ingredients is missing. This is a workaround I found, but this feels like it defeats the purpose of the exported types if I am assuming ingredients exists on the recipe object? I feel like I am missing something and shouldnt have to construct the type in my ts files. Is there any way to enforce nested objects be included?
export type Recipe = Prisma.RecipeGetPayload<{
include: { ingredients: true };
}>;
export type Recipe = Prisma.RecipeGetPayload<{
include: { ingredients: true };
}>;
I will include my schemas and exported types below: Schemas
model Recipe {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

name String
description String @db.VarChar(255)
instructions String @db.VarChar(255)
authorId String

ingredients IngredientInRecipe[]
@@index([authorId])
}

model Ingredient {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

name String @unique

recipes IngredientInRecipe[]
}

model IngredientInRecipe {
ingredientId String @default(cuid())
recipeId String @default(cuid())
name String
quantity Int
unit String

ingredient Ingredient @relation(fields: [ingredientId], references: [id])
recipe Recipe @relation(fields: [recipeId], references: [id])

@@id([ingredientId, recipeId])
}
model Recipe {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

name String
description String @db.VarChar(255)
instructions String @db.VarChar(255)
authorId String

ingredients IngredientInRecipe[]
@@index([authorId])
}

model Ingredient {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

name String @unique

recipes IngredientInRecipe[]
}

model IngredientInRecipe {
ingredientId String @default(cuid())
recipeId String @default(cuid())
name String
quantity Int
unit String

ingredient Ingredient @relation(fields: [ingredientId], references: [id])
recipe Recipe @relation(fields: [recipeId], references: [id])

@@id([ingredientId, recipeId])
}
Exported Recipe Type
type Recipe = {
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
description: string;
instructions: string;
authorId: string;
}
type Recipe = {
id: string;
createdAt: Date;
updatedAt: Date;
name: string;
description: string;
instructions: string;
authorId: string;
}
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server