chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
579 stars 43 forks source link

Option to prevent Prisma.X type annotations #169

Open Nmans01 opened 11 months ago

Nmans01 commented 11 months ago

Hello,

I am using zod-prisma-types in conjunction with TS-REST to build api contracts based on my prisma schema. The intention is that TS-Rest and the generated Zod schemas can together make a shared API package that can be consumed by both my frontend and backend apps for end-to-end type safety.

The way I intended for it to work is as follows. My prisma schema would live inside of my backend app folder in my monorepo, and zod-prisma-types would output into the api package when the client is generated in dev. This would allow for my schema.prisma to be the single source of truth that my api is based on, while preventing any need for copy-paste as progressive changes are made to the schema.

The only issue I am having is that, in the generated schema file, the type annotations which use z.ZodType cause ts(2742) errors to be thrown when importing my api package to any app, due to the reliance on types from the api package's node_modules folder.

Can an option be added to omit Prisma-based type annotations? If the schema does not rely on Prisma, then it can be consumed in a package by any app, not just the one housing the Prisma client.