fix(postprocess): merge ParentOnTypeNames when combining sibling object fields#1392
Open
fix(postprocess): merge ParentOnTypeNames when combining sibling object fields#1392
Conversation
…ct fields When merging sibling object fields from different concrete type inline fragments (step 4 of merge_fields.go), ParentOnTypeNames was not merged — only the first type's conditions were kept, causing the field to be silently skipped at resolve time for all other types. Fix: extract ParentOnTypeNames merge logic into mergeParentOnTypeNames and call it in step 4 after mergeValues, mirroring what step 5 already does for scalar fields. Fixes wundergraph/cosmo#2346 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Contributor
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughThis PR adds a regression test for merging concrete types in root field and interface fragments. It introduces GraphQL schema definitions, Go model types, resolvers, and test queries to replicate the scenario, while enhancing the engine's field merging logic to properly propagate and merge ParentOnTypeNames during sibling field deduplication. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
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 by CodeRabbit
Bug Fixes
Tests
Fixes a bug where deeply nested fields go missing from responses when a named fragment on an interface contains inline fragments for multiple concrete types and the non-matching type's fragment is defined first (cosmo#2346).
Root cause: In
merge_fields.gostep 4, when merging sibling object fields from different concrete type fragments,ParentOnTypeNameswas not merged — only the first-processed type's conditions were kept. At resolve time,skipFieldOnParentTypeNamesthen silently dropped the field for all other types.Fix: Extract the
ParentOnTypeNamesmerge logic (already present for scalars in step 5) into a sharedmergeParentOnTypeNamesmethod and call it in step 4 aftermergeValues.Tests added:
merge_fields_test.go) confirming order-independentParentOnTypeNamesmergingProductA/ProductB/Basetypes in the accounts subgraphChecklist