omar-dulaimi / prisma-zod-generator

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

Fix schema generation for prisma preview feature - fullTextSearch #62

Closed Shahidul1004 closed 1 year ago

Shahidul1004 commented 1 year ago

Hi @omar-dulaimi, thanks for creating this awesome project. I would like to integrate a fix that is related to prisma preview feature.

References

https://www.prisma.io/docs/concepts/components/prisma-client/full-text-search

Description

If we use fullTextSearch (one of the preview features prisma offers) with MySQL or PostgreSQL, then prisma exports UserOrderByWithRelationAndSearchRelevanceInputObjectSchema instead of UserOrderByWithRelationInputObjectSchema. Screenshot from 2022-12-08 20-01-02 Screenshot from 2022-12-08 20-02-00

But in the transformer class while generating model schemas, currently we statically import the UserOrderByWithRelationInputObjectSchema. So I have added a resolve function that will return an import and zod-schema-line(like we do for include and select field) for orderBy field.

omar-dulaimi commented 1 year ago

Hey @Shahidul1004 thanks for the PR! I'm facing this issue:

image

For the same schema in the repo.

Shahidul1004 commented 1 year ago

Could you please share what the problem is here? Because I am not getting any issues.

  1. From the screenshot you provide, I assume the generator does not generate the file UserOrderByWithRelationInput. Sometimes vs code fails to track new files. Could you please restart the vs code and see if it gets solved? I also face this issue.
  2. If that's not the case, could you please confirm which file the generator actually generating after looking into the objects folder? Is it generating any of these two files(UserOrderByWithRelationInput or UserOrderByWithRelationAndSearchRelevanceInputObjectSchema)? Or no file is being generated at all?
omar-dulaimi commented 1 year ago

Hey @Shahidul1004 I'll get back to you on this and other issues very soon. Just trying to get tRPC v10 released today :)

omar-dulaimi commented 1 year ago

All good!

omar-dulaimi commented 1 year ago

Released in https://github.com/omar-dulaimi/prisma-zod-generator/releases/tag/0.8.5

Thank you @Shahidul1004