On generation, the Address is not generated.
https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-composite-types
The current workaround:
// configs.js
replacer: (str, section) => {
if (section === 'crud.model.object') {
return str.replace(
"type: Inputs.Address,",
'type: "Json", // Mongodb Types not working yet',
);
}
return str;
},
Example schema with error
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator pothos {
provider = "prisma-pothos-types"
// Match client output location from above
clientOutput = "./client"
output = "./generated.d.ts"
}
generator pothosCrud {
provider = "prisma-generator-pothos-codegen"
generatorConfigPath = "../src/schema/configs.js"
}
model Post {
id String @id @default(auto()) @map("_id") @db.ObjectId
slug String @unique
title String
body String
Author User @relation(fields: [authorId], references: [id])
authorId String @db.ObjectId
}
model User {
id String @id @default(auto()) @map("_id") @db.ObjectId
email String @unique
name String?
Address Address?
Posts Post[]
}
// Address is an embedded document
type Address {
street String
city String
state String
zip String
}
On generation, the
Addressis not generated.https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-composite-types
The current workaround:
Example schema with error