Handling the size of the generated schemas #190
-
This library seems to offer everything I need to handle validation based on models generated from my database definition. However, I get 763 files (I'm currently trying Is there any advice/guidance you can provide regarding how to efficiently utilize the produced types/schemas? My database schema only has eight tables, although next-auth uses four additional ones. Just in case it is useful, I'm also using And sorry if this comment is funny but I'm utilizing a decent enough computer. Thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
@joacoespinosa no worries, this comment is not funny. I sometimes experience this behaviour myself and it can be annoying. I sadly do not have a bulletproof method how this behavior of typescript could be improved since there is a lot of type inference going on with zod in general that can lead to a degrading typescript perfomance - the amount of generated schemas does not help with this. Sadly there is no solution to reduce the amount of schemas other than disabling input schemas in general with The problem lies in the complexity of the data in the So sadly you'll have to live with this problem for now. 😞 |
Beta Was this translation helpful? Give feedback.
-
I encountered a similar problem, but I discovered that you can utilize either the Model Schema or the type itself for the form values. Simply employ the CreateInputSchema with the Zod validator, assuming that's what you're using. Try something like this type Input = z.infer<typeof TbaseSchema>;
const resolver = zodResolver(TbaseCreateWithoutBaseInputSchema);
const {
register,
handleSubmit,
reset,
clearErrors,
formState: { errors },
} = useForm<Input>({ resolver }); |
Beta Was this translation helpful? Give feedback.
@joacoespinosa no worries, this comment is not funny. I sometimes experience this behaviour myself and it can be annoying. I sadly do not have a bulletproof method how this behavior of typescript could be improved since there is a lot of type inference going on with zod in general that can lead to a degrading typescript perfomance - the amount of generated schemas does not help with this.
Sadly there is no solution to reduce the amount of schemas other than disabling input schemas in general with
createInputTypes = false
and create necessary validation schemas e.g. fortrpc
orreact-hook-forms
by hand.The problem lies in the complexity of the data in the
prisma dmmf
which is the basis fo…