Non-nullable self-referencing relations
Open
@kettanaito is already working on this.
Since Oct 5, 2025.
- Dominant language
- TypeScript
- Stars
- 1.1k
- Forks
- 67
- Avg merge
- 9m
- Merged PRs (30d)
- 5
Description
It is currently impossible to provide a self-referencing object(s) to Zod (I believe any schema library) as it will attempt to crawl it deeply and end up stuck in an infinite loop. Currently, this is circumvented by:
- Circular relations being marked as
.optional()so their values in the schema are not required. - All relations are detected when sanitizing and replaced with
.getDefaultValue()from the appropriate relation class.
Need to decide if this is acceptable or a better approach can be recommended.
- Sucks interfering with the user-defined schema. Some relations may be required but there's no way to describe that.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.