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
{{ message }}
Repository navigation
Add maxDepth Option to Handle Circular References in Validation Schema Generation #1039
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.
In this case, Movie references MovieAlternativeTitle, which in turn references Movie, 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.
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.
Activity
Code-Hex commentedon Apr 25, 2026
Fixed in #1423. Zod and Zod v4 object schemas now support maxDepth for cyclic output graphs, including cycles that pass through unions.