Strip T | null unions in mutation engine via replace()#73
Merged
FionaBronwen merged 2 commits intofeature/graphqlfrom Apr 8, 2026
Merged
Strip T | null unions in mutation engine via replace()#73FionaBronwen merged 2 commits intofeature/graphqlfrom
FionaBronwen merged 2 commits intofeature/graphqlfrom
Conversation
e5fb312 to
294c410
Compare
steverice
reviewed
Apr 6, 2026
Replace nullable wrapper unions (T | null) with the inner type using MutationNode.replace(), so downstream code sees the unwrapped type. Nullability is tracked via the setNullable() state map. Extracts getNullableUnionType() from isNullableWrapper() to support the replace() call.
294c410 to
2e79dcf
Compare
steverice
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MutationNode.replace()to swapT | nullwrapper unions with the inner type, so downstream code sees the unwrapped type instead of a two-variant unionsetNullable()state mapgetNullableUnionType()fromisNullableWrapper()to support thereplace()callMotivation
Previously, nullable wrapper unions (
string | null,Dog | null) were kept structurally intact — the mutation calledmutate()and marked the source union as nullable. This meant downstream code had to re-detectT | nullstructurally. Withreplace(), the union node is swapped out in the mutation graph and parent edges (e.g. a ModelProperty's type) update automatically. After mutation,property.typeis thestringscalar, notstring | null.Test plan
mutatedType.kindis the inner type (Scalar/Model) rather thanUnionisNullableonmutation.mutatedTypeinstead of the source unionT | nullon a model property is unwrapped to the inner type at the property level