Add maxDepth
Option to Handle Circular References in Validation Schema Generation
#1039
Labels
good first issue
Good for newcomers
Description:
I'm encountering issues with circular references in my GraphQL schema when using the
graphql-codegen-typescript-validation-schema
plugin. The generated validation schemas (e.g., for Zod) result in infinite recursion or stack overflow errors due to self-referencing types.For example, consider the following schema:
In this case,
Movie
referencesMovieAlternativeTitle
, which in turn referencesMovie
, creating a circular dependency.To mitigate this, I propose adding a
maxDepth
configuration option to the plugin. This option would allow users to specify the maximum depth for nested validation schema generation, preventing infinite recursion by limiting how deeply nested schemas are generated.Proposed Configuration:
Implementing this feature would enhance the plugin's robustness, especially for schemas with complex relationships, and align it with similar options available in other plugins like
typescript-mock-data
.Thank you for considering this enhancement!
The text was updated successfully, but these errors were encountered: