Skip to content

Commit

Permalink
fix: remove anyOf for one-to-many relations (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
foyarash authored Jan 21, 2025
1 parent 0eaafde commit 7933009
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-dolphins-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@premieroctet/next-admin-generator-prisma": patch
---

fix: remove anyOf for one-to-many relations (#513)
10 changes: 10 additions & 0 deletions apps/example/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,19 @@ export const options: NextAdminOptions = {
icon: "UserIcon",
list: {
display: ["id", "user"],
fields: {
user: {
formatter: (user) => user.email,
},
},
},
edit: {
display: ["user", "bio"],
fields: {
user: {
optionFormatter: (user) => user.email,
},
},
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions packages/generator-prisma/src/dmmf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ export const insertDmmfData = (
relation: getRelationData(dmmf, dmmfField, dmmfModel.name),
}
);

if (
dmmfField.kind === "object" &&
(model.properties![propertyName] as NextAdminJSONSchema)?.anyOf
) {
delete (model.properties![propertyName] as NextAdminJSONSchema).anyOf;
}
}
});
});
Expand Down

0 comments on commit 7933009

Please sign in to comment.