Closed pavelmasekcmgx closed 1 month ago
Is there some kind of common way how to deal with the cyclic reference of the graph?
Let's imagine graph like this one.
type Query { user(id: ID): User location(id: ID): Location } type User { id: ID! ... location?: Location } type Location { id: ID! ... user?: User }
that will generate mock functions
function anUser(...) {...} function aLocation(...) {...}
calling those functions will result in Maximum call stack size exceeded
Maximum call stack size exceeded
I can imagine something like altering of the fieldGeneration in the plugin config.
fieldGeneration
fieldGeneration: User: location: aLocation({user: null}) Location: user: anUser({location: null})
but this becomes quite complicated in case of more complex graph where the cyclic reference appears on some nested levels.
Have you tried this option? https://github.com/ardeois/graphql-codegen-typescript-mock-data?tab=readme-ov-file#terminatecircularrelationships-boolean-defaultvalue-false
That works like a charm I completely missed that in the readme. Thanks a lot 🙏
Is there some kind of common way how to deal with the cyclic reference of the graph?
Let's imagine graph like this one.
that will generate mock functions
calling those functions will result in
Maximum call stack size exceeded
I can imagine something like altering of the
fieldGeneration
in the plugin config.but this becomes quite complicated in case of more complex graph where the cyclic reference appears on some nested levels.