Closed mubaidr closed 1 year ago
This happens with tRPC v10, correct? If that was the case, then this should be resolved soon with the upgrade
No, I am using provider = "prisma-zod-generator"
(but i think it will be same with that too as it has dependency n this package)
Could you share a sample schema that produce this issue?
I think this issue could be related to previewFeature extendedWhereUnique
, it still happens with latest version:
"prisma-zod-generator": "^0.8.6"
I will try and check if disabling it solves the issue.
Update: Just tested this, It still shows error
I would appreciate it if you could share a schema that I could test on, so I could provide a fix for it
@mubaidr Still waiting for more details. What are you trying to accomplish with this library?
What exactly is invalid to you? I see ZodObject in the screenshot, though the library generates ZodType only.
Please clarify what exactly is the problem and sample code is possible.
Sorry for the delayed response.
I am trying to use generated zod schema to validate input in TRPC procedures.
Here is sample (part of whole schema, can't share complete due to licence issues) prisma
schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["extendedWhereUnique", "filteredRelationCount", "orderByNulls"]
}
generator zod {
provider = "prisma-zod-generator"
output = "./generated/zod"
isGenerateSelect = false
isGenerateInclude = false
}
// generator trpc {
// provider = "prisma-trpc-generator"
// output = "./generated/trpc"
// contextPath = "../context"
// withMiddleware = false
// withShield = false
// isGenerateSelect = false
// isGenerateInclude = false
// }
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
relationMode = "foreignKeys"
}
model City {
id Int @id @default(autoincrement())
title String @unique
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
venues Venue[]
@@map("city")
}
model Venue {
id Int @id @default(autoincrement())
code String @unique
title String @unique
address String
capacity Int
available Boolean @default(true)
cityId Int @map("city_id")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
updatedAt DateTime @default(now()) @map("updated_at") @db.Timestamptz
city City @relation(fields: [cityId], references: [id])
@@map("venue")
}
After running generate
command, zod schema is generated fine.
CityWhereUniqueInput.schema.ts
in ./generated/zod/schemas/object
, it will show error as shown in above screenshot, please.Thank you for the details. I just confirmed the existence of the bug, will work on it as soon as possible.
I did test it by disabling this preview feature here: https://github.com/omar-dulaimi/prisma-zod-generator/issues/59#issuecomment-1364678233
But maybe I have missed something.
P. S. Thanks for your awesome work.
Should be fixed in https://github.com/omar-dulaimi/prisma-zod-generator/releases/tag/0.8.10
Please confirm so I could update the tRPC generator as well
Sure, I will try and report here. 👍🏼
Yes, Its working good now! Thanks
Bug description
Generated schema for
ModelVacancyWhereUniqueInputObjectSchema
is invalid.How to reproduce
prisma
and generator versionprisma generate
ModelVacancyWhereUniqueInputObjectSchema
file for any modelExpected behavior
Generated schema should not contain any errors.
Prisma information
Environment & setup
Prisma Version