Skip to content

Non-nullable self-referencing relations #318

@kettanaito

Description

@kettanaito

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:

  1. Circular relations being marked as .optional() so their values in the schema are not required.
  2. 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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions