Open TamirCode opened 2 years ago
I think you need another generator, have you tried https://github.com/omar-dulaimi/prisma-class-validator-generator ?
I have tried all of these and many others too, it seems I am out of luck. The last one you linked does plan on adding this in the future however. It would be cool if you would add an option in your generator to generate non-graphql dtos so they can be used easily in the frontend, though I understand if you wont because this whole package is based on graphql. But I still see a use for it regardless, since frontend can use same validators.
my backend generates the DTOs but I also want to make use of them in the frontend wherein i have forms that also use class-validator. However, the generated DTOs make use of things like
@Field(() => companyWhereInput, {nullable:true})
which causes a lot of issues since it depends on @nestjs/graphql and if you install @nestjs/graphql on your frontend there is a ton of other unfixable errors. I want to generate DTOs that are compatible with my frontend and dont rely on a rabbit hole of nestjs graphql dependencies. For example, this:@Field(() => companyWhereInput, {nullable:true})
can be replaced with the class-validator equivalent:@IsOptional()
However I am aware that @Field has other reasons for its existence and not just determining nullable true/false. So let me know your thoughts on this and possibly other solutions because I am not an expert in using this package, thank you(my frontend uses Formik with
class-validator-formik
package)