Skip to content

Commit 78201c1

Browse files
[Fusion] Pop path in case of leftover (#8450)
1 parent b5b4f7b commit 78201c1

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

src/HotChocolate/Fusion/src/Core/Planning/Pipeline/ExecutionStepDiscoveryMiddleware.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ parentSelectionPath is null
156156

157157
if (!fieldInfo.Bindings.ContainsSubgraph(subgraph))
158158
{
159+
path.RemoveAt(pathIndex);
159160
(leftovers ??= []).Add(selection);
160161
continue;
161162
}

src/HotChocolate/Fusion/test/Core.Tests/DemoIntegrationTests.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,6 +2790,71 @@ query testQuery {
27902790
await snapshot.MatchMarkdownAsync();
27912791
}
27922792

2793+
[Fact]
2794+
public async Task Viewer_Bug_3() {
2795+
// arrange
2796+
var subgraphA = await TestSubgraph.CreateAsync(
2797+
"""
2798+
type Query {
2799+
viewer: Viewer!
2800+
}
2801+
2802+
type Viewer {
2803+
subgraphA: String!
2804+
}
2805+
""");
2806+
2807+
var subgraphB = await TestSubgraph.CreateAsync(
2808+
"""
2809+
type Query {
2810+
viewer: Viewer!
2811+
}
2812+
2813+
type Viewer {
2814+
subgraphB: String!
2815+
}
2816+
""");
2817+
2818+
var subgraphC = await TestSubgraph.CreateAsync(
2819+
"""
2820+
type Query {
2821+
subgraphC: SubgraphC!
2822+
}
2823+
2824+
type SubgraphC {
2825+
someField: String!
2826+
anotherField: String!
2827+
}
2828+
""");
2829+
2830+
using var subgraphs = new TestSubgraphCollection(output, [subgraphA, subgraphB, subgraphC]);
2831+
var executor = await subgraphs.GetExecutorAsync();
2832+
var request = Parse("""
2833+
query {
2834+
viewer {
2835+
subgraphA
2836+
subgraphB
2837+
}
2838+
subgraphC {
2839+
someField
2840+
anotherField
2841+
}
2842+
}
2843+
""");
2844+
2845+
// act
2846+
var result = await executor.ExecuteAsync(
2847+
OperationRequestBuilder
2848+
.New()
2849+
.SetDocument(request)
2850+
.Build());
2851+
2852+
// assert
2853+
var snapshot = new Snapshot();
2854+
CollectSnapshotData(snapshot, request, result);
2855+
await snapshot.MatchMarkdownAsync();
2856+
}
2857+
27932858
[Fact]
27942859
public async Task Two_Arguments_Differing_Nullability_Does_Not_Duplicate_Forwarded_Variables()
27952860
{
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Viewer_Bug_3
2+
3+
## Result
4+
5+
```json
6+
{
7+
"data": {
8+
"viewer": {
9+
"subgraphA": "string",
10+
"subgraphB": "string"
11+
},
12+
"subgraphC": {
13+
"someField": "string",
14+
"anotherField": "string"
15+
}
16+
}
17+
}
18+
```
19+
20+
## Request
21+
22+
```graphql
23+
{
24+
viewer {
25+
subgraphA
26+
subgraphB
27+
}
28+
subgraphC {
29+
someField
30+
anotherField
31+
}
32+
}
33+
```
34+
35+
## QueryPlan Hash
36+
37+
```text
38+
0343522DE0DDC505C43E45B0E95A7AED449C0B87
39+
```
40+
41+
## QueryPlan
42+
43+
```json
44+
{
45+
"document": "{ viewer { subgraphA subgraphB } subgraphC { someField anotherField } }",
46+
"rootNode": {
47+
"type": "Sequence",
48+
"nodes": [
49+
{
50+
"type": "Parallel",
51+
"nodes": [
52+
{
53+
"type": "Resolve",
54+
"subgraph": "Subgraph_3",
55+
"document": "query fetch_viewer_subgraphC_1 { subgraphC { someField anotherField } }",
56+
"selectionSetId": 0
57+
},
58+
{
59+
"type": "Resolve",
60+
"subgraph": "Subgraph_1",
61+
"document": "query fetch_viewer_subgraphC_2 { viewer { subgraphA } }",
62+
"selectionSetId": 0
63+
},
64+
{
65+
"type": "Resolve",
66+
"subgraph": "Subgraph_2",
67+
"document": "query fetch_viewer_subgraphC_3 { viewer { subgraphB } }",
68+
"selectionSetId": 0
69+
}
70+
]
71+
},
72+
{
73+
"type": "Compose",
74+
"selectionSetIds": [
75+
0
76+
]
77+
}
78+
]
79+
}
80+
}
81+
```
82+

0 commit comments

Comments
 (0)