Keep a selection of only __typename as a struct, not an empty enum - #573
Open
antonshevchenko wants to merge 1 commit into
Open
Conversation
`ExpandedSelection::render` turns a fieldless struct into the enum of its
variants. With no variants either -- a union member narrowed to with nothing
but `__typename` -- that produced `enum X {}`, which cannot deserialize.
Co-authored-by: Cursor <cursoragent@cursor.com>
antonshevchenko
marked this pull request as ready for review
August 5, 2026 00:33
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.
A union member selected with only
__typenamegenerates an enum with no variants. Nothing can deserialize into it.DoThingSuccesscarries no fields, so__typenameis the only thing there is to select. The generated payload type comes out aspub enum ExampleDoThingOnDoThingSuccess {}, and any response naming that member fails to decode.The cause is in
ExpandedSelection::render, where a selection with no fields is turned into the enum of its variants. A selection of only__typenamehas no fields and no variants, so it becomes an empty enum. Requiring at least one variant leaves it as a struct, which deserializes from any object.