Skip to content

Commit 22cc584

Browse files
Cleanup
1 parent d6e5953 commit 22cc584

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/Nodes/OperationExecutionNode.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public OperationExecutionNode(
5757

5858
_variables = variables.ToArray();
5959

60-
// TODO: This might include requirements that we wouldn't want to create a front-end facing error for
61-
// TODO: How to deal with selections on a specific type? Creating errors for all possible response names is wrong
6260
_responseNames = GetResponseNamesFromPath(operation, source);
6361
}
6462

@@ -332,13 +330,21 @@ private static ImmutableArray<string> GetResponseNamesFromPath(
332330

333331
var responseNames = new List<string>();
334332

335-
foreach (var selection in selectionSet.Selections)
333+
var stack = new Stack<ISelectionNode>(selectionSet.Selections);
334+
335+
while (stack.TryPop(out var selection))
336336
{
337-
// TODO: We need to handle InlineFragmentNodes here
338337
if (selection is FieldNode fieldNode)
339338
{
340339
responseNames.Add(fieldNode.Alias?.Value ?? fieldNode.Name.Value);
341340
}
341+
else if (selection is InlineFragmentNode inlineFragmentNode)
342+
{
343+
foreach (var child in inlineFragmentNode.SelectionSet.Selections)
344+
{
345+
stack.Push(child);
346+
}
347+
}
342348
}
343349

344350
return [..responseNames];
@@ -359,7 +365,6 @@ private static ImmutableArray<string> GetResponseNamesFromPath(
359365

360366
if (segment.Kind == SelectionPathSegmentKind.InlineFragment)
361367
{
362-
// TODO: Do we need to handle the case without a type condition?
363368
var selection = current.Selections
364369
.OfType<InlineFragmentNode>()
365370
.FirstOrDefault(s => s.TypeCondition?.Name.Value == segment.Name);
@@ -381,6 +386,7 @@ private static ImmutableArray<string> GetResponseNamesFromPath(
381386
{
382387
return null;
383388
}
389+
384390
current = selection.SelectionSet;
385391
}
386392
}

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/Results/ValueCompletion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void BuildErrorResult(
8989
{
9090
var fieldResult = objectResult[responseName];
9191

92-
if (!fieldResult.Selection.IsIncluded(_includeFlags))
92+
if (fieldResult.Selection.IsInternal || !fieldResult.Selection.IsIncluded(_includeFlags))
9393
{
9494
continue;
9595
}

src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/SubgraphErrorTests.No_Data_And_Error_Without_Path_For_Lookup.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"message": "A global error"
55
},
66
{
7-
"message": "Unexpected execution error",
7+
"message": "Unexpected Execution Error",
88
"path": [
99
"topProduct",
1010
"name"

src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/SubgraphErrorTests.No_Data_And_Error_Without_Path_For_Root_Field.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"message": "A global error"
88
},
99
{
10-
"message": "Unexpected execution error",
10+
"message": "Unexpected Execution Error",
1111
"path": [
1212
"productById"
1313
]

0 commit comments

Comments
 (0)