You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading data for further parsing with zod, one would often not want to have infinitely nested relations. For example, I have Author and Post in a relation. I want to parse a Post with Author, but the Author within the post does not carry the reference to its Posts anymore.
Unfortunately, the generated PostWithRelations will reference AuthorWithRelations instead of Author.
It would be easy to fix this - either removing the WithRelations in the code referenced below (would be a breaking change though), or copying it and adding one more type like PostWithUnidirectionalRelations. I have a hard time thinking of a use-case for the current behavior of the WithRelations classes though - any data loaded from a DB (or anywhere) will likely not have the recursive reference structure that would make it parseable.
When loading data for further parsing with zod, one would often not want to have infinitely nested relations. For example, I have
Author
andPost
in a relation. I want to parse aPost
withAuthor
, but theAuthor
within the post does not carry the reference to itsPosts
anymore.Unfortunately, the generated
PostWithRelations
will referenceAuthorWithRelations
instead ofAuthor
.It would be easy to fix this - either removing the
WithRelations
in the code referenced below (would be a breaking change though), or copying it and adding one more type likePostWithUnidirectionalRelations
. I have a hard time thinking of a use-case for the current behavior of theWithRelations
classes though - any data loaded from a DB (or anywhere) will likely not have the recursive reference structure that would make it parseable.https://github.com/chrishoermann/zod-prisma-types/blob/6ed3d90a946bb9a4a0d67f2785b4529337a6226d/packages/generator/src/functions/contentWriters/writeModelOrType.ts#L227C15-L227C44
The text was updated successfully, but these errors were encountered: