Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive relations lead to parsing problems #304

Open
MischaPanch opened this issue Dec 29, 2024 · 0 comments
Open

Recursive relations lead to parsing problems #304

MischaPanch opened this issue Dec 29, 2024 · 0 comments

Comments

@MischaPanch
Copy link

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.

https://github.com/chrishoermann/zod-prisma-types/blob/6ed3d90a946bb9a4a0d67f2785b4529337a6226d/packages/generator/src/functions/contentWriters/writeModelOrType.ts#L227C15-L227C44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant