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
When using the plugin API to add new fields to the graphql schema (using setFieldsOnGraphQLNodeType), if the subtree under my added fields contains any circular references (for example, custom field relatedBooks of type RelatedBooks might point to Author and then back to Book -> RelatedBooks type again), I end up with a Maximum call stack size exceeded error that points back to infer-graphql-input-fields-from-fields, where the automated detection of fields is infinitely traversing the tree of self-referential types until memory crashes.
What's the best way to solve this one? In my use case, I can't really avoid some circularity without losing the entire purpose of my plugin. Would it be best to pursue a way for plugins to manually disable the input fields inference (although I don't see any of the other "hook" functions taking top-level options, so not clear how best to structure that without breaking backwards functionality), or would it be better to simply dive deep into that recursive inference function and prevent infinite recursion by tracking types already seen?
The functionality causing the issue was added back in #2075
The text was updated successfully, but these errors were encountered:
I should add that I've tested hard-disabling the input fields inference function in a local branch of gatsby, and that indeed solved the problem; circularity does not break any other part of gatsby's graphql schema layer, only the input type inference.
When using the plugin API to add new fields to the graphql schema (using
setFieldsOnGraphQLNodeType
), if the subtree under my added fields contains any circular references (for example, custom field relatedBooks of typeRelatedBooks
might point toAuthor
and then back toBook
->RelatedBooks
type again), I end up with a Maximum call stack size exceeded error that points back toinfer-graphql-input-fields-from-fields
, where the automated detection of fields is infinitely traversing the tree of self-referential types until memory crashes.What's the best way to solve this one? In my use case, I can't really avoid some circularity without losing the entire purpose of my plugin. Would it be best to pursue a way for plugins to manually disable the input fields inference (although I don't see any of the other "hook" functions taking top-level options, so not clear how best to structure that without breaking backwards functionality), or would it be better to simply dive deep into that recursive inference function and prevent infinite recursion by tracking types already seen?
The functionality causing the issue was added back in #2075
The text was updated successfully, but these errors were encountered: