Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Create a package with no dependencies to @prisma/client #279

Open
vorillaz opened this issue Oct 9, 2024 · 0 comments

Comments

@vorillaz
Copy link

vorillaz commented Oct 9, 2024

Is your feature request related to a problem? Please describe.
Hi there, thanks for this amazing generator. We are trying to export the schema validation inside a monorepo. The reason is kind of reusing the schema as validation for forms in the frontend and the backend. When the schema types are generated in a different package inside the monorepo though the @prisma/client is not present. We are trying to use the package as follow:

// ./packages/db/prisma/schema.prisma
generator zod {
  provider                         = "zod-prisma-types"
  output                           = "../../packages/zod/prisma"
  useMultipleFiles                 = true
  writeBarrelFiles                 = true
  createInputTypes                 = false
  addIncludeType                   = false
  addSelectType                    = false
  writeNullishInModelTypes         = false
  createOptionalDefaultValuesTypes = false
  addInputTypeValidation           = false
}

The generated output inside the packages/zod is not aware of the @prisma/client required from the generated output since it's a different package reused by both a client and backend application.

Describe the solution you'd like
Maybe provide our own types somehow through a config file like:

generator zod {
  provider                         = "zod-prisma-types"
  output                           = "./zod"
  // ..
  nullishTypes = "./zod-nullish"
}

Or somehow skip nullish checking through configuration.

Describe alternatives you've considered
A quick and dirty patch is to trick typescript to import @prisma/client as my own types through aliasing.

Once again thanks ton for your amazing work. Keep up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant