Repository navigation
refactor(clientgenv2): split NewResponseField by selection kind - #346
Merged
Merged
Conversation
This was referenced Sep 25, 2026
NewResponseField was a 198-line type switch that handled fields, fragment spreads, and inline fragments in one body, and the two inline fragment paths (with and without a fragment spread) repeated the same struct registration, pointer wrapping, and tag construction. Extract newFieldResponseField, fieldBaseType, fieldTags, newFragmentSpreadResponseField, newInlineFragmentResponseField, mergeInlineFragmentFields, inlineFragmentType, and inlineFragmentTags, and let the inline fragment path compute its field list once before a single shared tail. The duplicate-field merge from #358 lives in mergeInlineFragmentFields. Delete expandFragmentFields, which had no callers. No behavior change: the golden tests in generator, including the inline_fragment_duplicate_fields case from #358, and a regeneration of the local-schema examples produce identical output, and the test suite is untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Yamashou
force-pushed
the
refactor/clientgenv2-response-field
branch
from
October 1, 2026 05:57
879e2b3 to
6012290
Compare
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.
Background
SourceGenerator.NewResponseFieldwas a 198-line type switch (cognitive complexity 38) that handled*ast.Field,*ast.FragmentSpread, and*ast.InlineFragmentin one body. Inside the inline fragment case, the path with a fragment spread and the path without one repeated the same struct registration,InlineFragmentAlwaysPointershandling, andgraphql:"... on X"tag construction, so the two could drift independently.expandFragmentFieldshad no callers.Changes
Pure refactor; the test suite is untouched.
NewResponseFielddispatches tonewFieldResponseField,newFragmentSpreadResponseField, andnewInlineFragmentResponseField.fieldBaseType(scalar, fragment, or generated struct) andfieldTags(json and graphql tags, including the omitempty and omitzero options).inlineFragmentTypeandinlineFragmentTagshold the shared pieces. The special case that reuses a lone fragment spread's type is kept as is.expandFragmentFieldsis deleted.mergeInlineFragmentFieldshelper; theinline_fragment_duplicate_fieldsgolden case verifies it.The order of side effects on
r.StructSourcesand the point at whichSortByNameruns are preserved, which is what the generated struct field order depends on.Testing
The golden tests in
generatorpass unchanged, and regenerating the seven local-schema examples underexample/produces no diff. The workflow was also run locally withactand the Build job passed.