Skip to content

Commit

Permalink
Merge pull request #903 from lsmacedo/handle-unavailable-create-input…
Browse files Browse the repository at this point in the history
…-objects

stop using unavailable prisma CreateInput objects
  • Loading branch information
hayes committed May 7, 2023
2 parents a0a9350 + 5b6007c commit 6e730ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/few-turtles-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pothos/plugin-prisma": patch
---

Prevent unavailable prisma CreateInput types from being referenced by pothos generated types.
8 changes: 7 additions & 1 deletion packages/plugin-prisma/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ function buildTypes(dmmf: DMMF.Document, config: { prismaUtils?: string }) {
const relations = model.fields.filter((field) => !!field.relationName);
const listRelations = model.fields.filter((field) => !!field.relationName && field.isList);

const createInputUnavailable = !dmmf.schema.inputObjectTypes.prisma.some(
(input) => input.name === `${model.name}CreateInput`,
);

return ts.factory.createPropertySignature(
[],
model.name,
Expand Down Expand Up @@ -200,7 +204,9 @@ function buildTypes(dmmf: DMMF.Document, config: { prismaUtils?: string }) {
[],
'Create',
undefined,
ts.factory.createTypeReferenceNode(`Prisma.${model.name}CreateInput`),
createInputUnavailable
? ts.factory.createTypeLiteralNode([])
: ts.factory.createTypeReferenceNode(`Prisma.${model.name}CreateInput`),
),
ts.factory.createPropertySignature(
[],
Expand Down

1 comment on commit 6e730ab

@vercel
Copy link

@vercel vercel bot commented on 6e730ab May 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.