Repository navigation
Fix GraphQL fragment selection dropping trailing fields - #3862
Open
Joel Town Road (hippi345) wants to merge 2 commits into
Open
Joel Town Road (hippi345) wants to merge 2 commits into
Joel Town Road (hippi345) wants to merge 2 commits into
Conversation
AddGraphQLFields used return after expanding a fragment spread or inline fragment, which exited the selection loop and omitted later fields. Continue to the next selection instead.
HTTP fragment queries do not hit AddGraphQLFields' fragment branches on Hot Chocolate 16, so keep only the unit test that covers the loop.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Author
|
@microsoft-github-policy-service agree |
Joel Town Road (hippi345)
marked this pull request as ready for review
October 17, 2026 01:32
Joel Town Road (hippi345)
requested review from
Alekhya-Polavarapu,
Aniruddh Munde (Aniruddh25),
RubenCerna2079,
aaronburtle,
cwebb-msft,
Mohit G (gmohit21),
mhyon,
rusamant,
Sourabh Jain (sourabh1007),
Souvik Ghosh (souvikghosh04),
Stuart Padley (stuartpa) and
vadeveka
as code owners
October 17, 2026 01:32
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused control-flow fix preserves trailing selections, and the regression test directly covers the failure.
No open issues 🎉
What changed in this PR
Fixes a latent SQL GraphQL selection bug from #3861 that drops fields following fragments.
Changes:
- Continues processing selections after named and inline fragments.
- Adds a direct regression test for fields following an inline fragment, bypassing Hot Chocolate 16’s fragment normalization.
| File | Description |
|---|---|
| src/Service.Tests/UnitTests/SqlQueryStructureHelperTests.cs | Adds regression coverage and supporting metadata setup. |
| src/Core/Resolvers/Sql Query Structures/SqlQueryStructure.cs | Replaces early returns with loop continuation after fragment expansion. |
Review effort: Balanced
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.
Why make this change?
SqlQueryStructure.AddGraphQLFields, expanding a fragment spread or inline fragment usedreturn;, which exits the selectionforeachinstead of moving to the next node.AddGraphQLFieldsruns). The issue was reported on 2.1.5, which uses the same Hot Chocolate version, so the HTTP reproduction may depend on conditions we couldn't recreate. The code bug is real, and the unit test covers the loop.What is this change?
FragmentSpreadorInlineFragment,AddGraphQLFieldscontinues to the next selection instead of returning from the method.AddGraphQLFields_ContinuesAfterInlineFragmentcallsAddGraphQLFieldsdirectly with an inline fragment followed by another field, covering the selection loop.How was this tested?
With the fix reverted (
return;in both fragment branches), the unit test failed because the trailing field was dropped:With
continue;applied:(The 34-test run is
FullyQualifiedName~SqlQueryStructureHelperTests, which includesSqlQueryStructureHelperTestsand nearbyBaseSqlQueryStructureHelperTests.)Sample Request(s)
GraphQL query that would drop trailing fields when AddGraphQLFields receives unexpanded fragments (exercised directly by the unit test):
On current main with Hot Chocolate 16, the engine merges those fragment selections before
AddGraphQLFields, so this HTTP query is not a reproduction. The unit test is the coverage for the loop.This change was prepared with AI assistance. I remain responsible for the contribution and have reviewed it.