Open sfratini opened 4 years ago
I have a similar issue with relation tables. This is my Prisma schema:
model User {
id Int @default(autoincrement()) @id
email String @unique
relationship1 Relationship[] @relation("Relationship_userId1ToUser")
relationship2 Relationship[] @relation("Relationship_userId2ToUser")
}
model Relationship {
userId1 Int
userId2 Int
user1 User @relation("Relationship_userId1ToUser", fields: [userId1], references: [id])
user2 User @relation("Relationship_userId2ToUser", fields: [userId2], references: [id])
@@id([userId1, userId2])
}
These are my generated Prisma client types:
export type UserWhereUniqueInput = {
id?: number
email?: string
}
export type UserCreateOneWithoutRelationship1Input = {
create?: UserCreateWithoutRelationship1Input
connect?: UserWhereUniqueInput
}
export type UserCreateOneWithoutRelationship2Input = {
create?: UserCreateWithoutRelationship2Input
connect?: UserWhereUniqueInput
}
export type RelationshipCreateInput = {
user1: UserCreateOneWithoutRelationship1Input
user2: UserCreateOneWithoutRelationship2Input
}
It seems like Nexus validation fails when RelationshipCreateInput
has no other fields except relational inputs.
If I add a empty: String?
field to my User
schema, then the generated Prisma type will be:
export type RelationshipCreateInput = {
empty?: string | null
user1: UserCreateOneWithoutRelationship1Input
user2: UserCreateOneWithoutRelationship2Input
}
and Nexus validation passes.
I can also add this happens if you add any of the upsert methods. In my case, I cannot find any combination that would make the validation pass. It has become a blocking issue for me.
Nexus Report
The report is breaking:
TypeError: Object.fromEntries is not a function
Screenshot
Package.json
Mutations:
Error on nexus dev:
Schema Prisma:
Prisma client with an empty array of fields for this object:
{\"name\":\"CompanyUserUpdateManyDataInput\",\"isOneOf\":false,\"fields\":[]}
Description
Basically, I cannot add none of the opdateOne methods, because it will complain that the ManyDataInput are empty. This does not happen with all of them, as some have fields (other XXXManyDataInput objects).
I am unable to determine why this models are not being generated.
Any information I can attach, let me know.