omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
516 stars 45 forks source link

Part of zod methods are not available after import #25

Open lunacrafts opened 2 years ago

lunacrafts commented 2 years ago

Bug description

inside of ModelCreateInputObjectSchema file, I can see those properties.

Screenshot 2022-09-22 at 07 39 29

but after I import it It's undefined

Screenshot 2022-09-22 at 07 39 49
lunacrafts commented 2 years ago

I made changes (https://github.com/lunacrafts/prisma-zod-generator/commit/292d4ccccec180f210b70c732a3f447a246c4636) after which I'm able to make: Screenshot 2022-09-22 at 09 43 40

Screenshot 2022-09-22 at 09 43 15
omar-dulaimi commented 1 year ago

Hey @lunacrafts It's great that you managed to fix this issue, happy that it worked for you. How do you feel about submitting a PR for this?

Also, do you think there are any side effects to exporting the schema and the type like that?

lunacrafts commented 1 year ago

Hello @omar-dulaimi

First of all, my changes broke other part of your package, so at some point I had to resign from it (and from prisma as well), so unfortunately I'm not able to make and test PR.

Second of all, in the meantime I figured out my approach with type infering from zod would use a lot of memory during development so It's no-go solution. I don't know in-depth zod API so I'm not going to be helpful in any matter.

omar-dulaimi commented 1 year ago

Sad to hear that @lunacrafts I'm sure there are other ways to fix this, especially if we ask the author of zod himself. I appreciate you taking the time to use this project, and hopefully this issue would be resolved soon.

There are alternatives to zod, like joi, yup and class validator. Maybe they could be useful to your case.

lunacrafts commented 1 year ago

The real issue for me was prisma. Im in the phase of prototyping application (with mongodb) and Prisma hold me back in this case. It's great for CRUD and basic database operations, but I couldn't really use core features of mongo.

I really appreciated using prisma + prisma-zod-generator + trpc + next but I run into some limitations what made this setup of tools kinda useless. One of those is that I was able to generate awesome end-to-end typesafe queries, but I wasn't able to intercept anywhere on the backend side, so for example I couldn't apply access-control rules to resources.

It is awesome, but just not in my use case! Really appreciate your work on this package and I'm sure I'll use it in another part of project but just not yet.