Open ramiel opened 1 year ago
Can you share related part of your Prisma schema?
This is the relevant section
model Caption {
/// @TypeGraphQL.omit(input: ["create"])
id String @id @default(auto()) @map("_id") @db.ObjectId
/// @TypeGraphQL.omit(input: true)
createdAt DateTime @default(now())
/// @TypeGraphQL.omit(input: true)
updatedAt DateTime @updatedAt
/// @TypeGraphQL.omit(input: true)
projectId String @db.ObjectId
interimId String?
isFinal Boolean
text String
sourceLanguage String
targetLanguage String
timestampStart BigInt
timestampEnd BigInt?
/// @TypeGraphQL.omit(input: true)
status CaptionStatus
captioner User? @relation(fields: [captionerId], references: [id], onDelete: SetNull, onUpdate: SetNull)
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade, onUpdate: Cascade)
revisions CaptionRevision[]
currentRevisionId String?
captionerId String? @db.ObjectId
@@unique([projectId, interimId, targetLanguage])
@@index([projectId, targetLanguage])
@@index([timestampStart(sort: Desc)])
}
I have the same error for any model though, so I don't think it's related to this in particular
I've encountered this for models with multi-columns unique indexes. This breaks TS typings because in Prisma 5.0 they use a TS trick to check if user provides either a primary key or the unique combination of fields. However, in GraphQL we can't enforce such constraints, so it now yells in compile-time that something is wrong.
I see. Any workaround we can put in place? I guess I can omit 'cursor' from my type, but this is not a global solution. Maybe the type of cursor should be any
while in graphql it keeps all the possible keys without enforcing just one?
related to this? https://github.com/prisma/prisma/issues/20619
We're seeing this with a model with only one unique field:
model RedactedModelName {
id String @id @default(uuid())
redactedId String
redactedField RedactedField @relation(fields: [redactedId], references: [id])
userId String
user User @relation(fields: [userId], references: [id])
reasonId String
reason DisputedReason @relation(fields: [reasonId], references: [id])
createdAt DateTime @default(now()) @db.Timestamptz
updatedAt DateTime @updatedAt @db.Timestamptz
status Status @default(OPEN)
notes String?
}
The generated FindManyRedactedModelNameArgs
type is not compatible with the expected type for prisma.redactedModel.findMany
I've added a hack around this for now:
export type TypegraphqlWorkAround<T> = T & { cursor?: any };
and then just declare/assert with:
TypegraphqlWorkAround<FindManyRedactedModelNameArgs>
Describe the Bug With the new prisma 5 version the type produced by code generation is wrong for the
cursor
type. This only happens with cursor, not the other properties. In the image belowFindManyCaptionArgs
comes from the type in the generate filepackages/prisma/dist/@generated/resolvers/crud/Caption/args/FindManyCaptionArgs.d.ts
To Reproduce Try to use the types generated from the package for find operations
Expected Behavior The type should match
Logs
Environment (please complete the following information):
typegraphql-prisma
0.27.0