omar-dulaimi / prisma-yup-generator

Prisma 2+ generator to emit Yup schemas from your Prisma schema
MIT License
52 stars 3 forks source link

don't generate redundant code #4

Closed Morriz closed 2 years ago

Morriz commented 2 years ago

Problem

Hi, all your objects/*.schema files contain redundant code. The top definition is always copied to be used in the exported Yup.object({....

Suggested solution

Just export like this:

export const UserUpdateInputObject = ...
...
export const UserUpdateInputObjectSchema = Yup.object(UserUpdateInputObject)
Morriz commented 2 years ago

It would also be really awesome if you could generate indexes so that we can just import like this:

import { UserUpdateInputObjectSchema } from `*/gen/schemas`
Morriz commented 2 years ago

I will create a separate issue for that ;)

omar-dulaimi commented 2 years ago
export const UserUpdateInputObject = ...
...
export const UserUpdateInputObjectSchema = Yup.object(UserUpdateInputObject)

This would be really cool if it works and doesn't show any errors. Hopefully it works!

omar-dulaimi commented 2 years ago

Fixed in 0.1.3