Bug description
Hi,
I have a problem getting implicit many-to-many relations to work with the generated code.
Attached you find my schema and client-code.
Problem is, VSCode and Angular Live Deployment Server both show the same TypeScript error, related to the generated type:
error TS2739: Type '{ create: { id: number; name: string; }[]; }' is missing the following properties from type '{ connect: { id: number; } | { id: number; }[]; create: { name: string; } | { name: string; id: number; } | { name: string; }[] | { name: string; id: number; }[]; connectOrCreate: { create: { name: string; } | { ...; }; where: { ...; }; } | { ...; }[]; }': connect, connectOrCreate
53 tags: {
~~~~
./prisma/trpc/schemas/objects/ProjectUncheckedCreateWithoutAuthorInput.schema.ts:12:3
12 tags: z.object(TagUncheckedCreateNestedManyWithoutProjectsInputSchemaObject),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type comes from property 'tags' which is declared here on type '{ id: number; tags: { connect: { id: number; } | { id: number; }[]; create: { name: string; } | { name: string; id: number; } | { name: string; }[] | { name: string; id: number; }[]; connectOrCreate: { create: { name: string; } | { ...; }; where: { ...; }; } | { ...; }[]; }; ... 4 more ...; desc: string; }'
So the type needs all of create, connect & createOnConnect methods ?!
Or am I doing something else wrong ?
With plain prisma the same query is working perfectly.
How to reproduce
use my schema, the generator & my client code
Expected behavior
Type should work with create method only
Prisma information
schema:
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
email String @unique
name String?
password String?
projects Project[]
}
model Project {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
published Boolean @default(false)
title String
shortDesc String
desc String
author User @relation(fields: [authorId], references: [id])
authorId Int
tags Tag[]
}
model Tag {
id Int @id @default(autoincrement())
name String
projects Project[]
}
client-code:
trcp.mutation('user.createOneUser', {
data: {
email: '[email protected]',
name: 'Fabian Dreßen',
projects: {
create: [{
title: 'Sample project ',
shortDesc: 'BlaBla Blub',
desc: 'adasdasd dasdasdasd',
tags: {
create: [
{ name: 'sometag' },
{ name: 'anothertag' },
],
}
}],
}
}
});
Environment & setup
- OS: Ubuntu
- Database: SQLite
- Node.js version: v14.18.1
Prisma Version
prisma : 3.14.0
@prisma/client : 3.14.0
Current platform : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine : migration-engine-cli 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 2b0c12756921c891fec4f68d9444e18c7d5d4a6a
Studio : 0.460.0
bug