chrishoermann / zod-prisma-types

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

Is there a way to import for custom prisma location? #36

Closed pedropmedina closed 1 year ago

pedropmedina commented 1 year ago

Hi,

Is it possible to read the the generated prisma client from a custom output location. As of now the generator speculates that the location of prisma is at import * as PrismaClient from "@prisma/client";

Thanks

chrishoermann commented 1 year ago

Currently not. But this is a good idea and should be not too much of a problem to implement.

chrishoermann commented 1 year ago

should work now with version 1.2.0

pedropmedina commented 1 year ago

Hey @chrishoermann ,

Thanks for the quick update. It's working! The only thing I noticed it's that you left behind some logs

config { prismaClientPath: '../client' }
parsedConfig {
  useInstanceOfForDecimal: false,
  imports: [],
  createInputTypes: true,
  addInputTypeValidation: true,
  prismaClientPath: '../client'
}
chrishoermann commented 1 year ago

Thnx for the hint, I'll remove them.

chrishoermann commented 1 year ago

logs removed in v1.2.1

chrishoermann commented 1 year ago

Closing since it works in current version

pedropmedina commented 1 year ago

Hey Chris,

Quick question. Wouldn't you be able to auto locate the output location for the prisma client? I noticed prisma-zod-generator does it. This way we wouldn't have to opt in for this option?

chrishoermann commented 1 year ago

Thanks for the hint @pedropmedina. I wasn't aware of that. I'm a bit short on time the next few days but I'll definitly look into this

chrishoermann commented 1 year ago

@pedropmedina the automatic detection of the prisma client location should work in v1.3.6.

pedropmedina commented 1 year ago

Hi @chrishoermann

I tested it this new version and the location to the PrismaClient seems incorrect. For instance here's my tree for generated files: /generated/client/ /generated/zod-prisma-types/ /genereated/other-generators...

In v1.3.6 you're pulling the client from import * as PrismaClient from "../generated/client"; The correct path should be ../client in my case.

I will be reverting back to previous version for now

chrishoermann commented 1 year ago

Hey @pedropmedina

sorry my bad. I used the wrong reference path when getting the relative path of the client. It should work in v1.3.7 now.

pedropmedina commented 1 year ago

Np @chrishoermann. It's working correctly now. Thanks a lot for the quick response.

chrishoermann commented 1 year ago

You're welcome