Skip to content

Commit e5f6ade

Browse files
[Fusion] RawOperationResult.Errors should be null if there are no errors (#8839)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 98e0ca6 commit e5f6ade

File tree

6 files changed

+35
-47
lines changed

6 files changed

+35
-47
lines changed

src/HotChocolate/AspNetCore/benchmarks/k6/performance-data.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
2-
"timestamp": "2025-10-23T10:04:55Z",
2+
"timestamp": "2025-10-23T08:31:24Z",
33
"tests": {
44
"single-fetch": {
55
"name": "Single Fetch (50 products, names only)",
66
"response_time": {
7-
"min": 1.354974,
8-
"p50": 1.917465,
9-
"max": 39.045215,
10-
"avg": 2.211277226896645,
11-
"p90": 3.051409,
12-
"p95": 3.6816645,
13-
"p99": 6.286266199999994
7+
"min": 1.360442,
8+
"p50": 1.74927,
9+
"max": 41.901381,
10+
"avg": 1.9882560501470818,
11+
"p90": 2.582531,
12+
"p95": 3.056496999999996,
13+
"p99": 5.826263539999997
1414
},
1515
"throughput": {
16-
"requests_per_second": 78.77656643800736,
17-
"total_iterations": 7162
16+
"requests_per_second": 78.79703615241581,
17+
"total_iterations": 7170
1818
},
1919
"reliability": {
2020
"error_rate": 0
@@ -23,17 +23,17 @@
2323
"dataloader": {
2424
"name": "DataLoader (50 products with brands)",
2525
"response_time": {
26-
"min": 2.690869,
27-
"p50": 4.002113,
28-
"max": 19.431387,
29-
"avg": 4.3774701576950115,
30-
"p90": 5.953583,
31-
"p95": 7.3601592999999905,
32-
"p99": 10.701773639999999
26+
"min": 2.629259,
27+
"p50": 3.337894,
28+
"max": 16.534475,
29+
"avg": 3.700613336003375,
30+
"p90": 4.795968,
31+
"p95": 5.8992587499999996,
32+
"p99": 9.208675050000002
3333
},
3434
"throughput": {
35-
"requests_per_second": 78.52895150550104,
36-
"total_iterations": 7146
35+
"requests_per_second": 78.60019900711032,
36+
"total_iterations": 7147
3737
},
3838
"reliability": {
3939
"error_rate": 0

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/OperationPlanContext.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ internal IOperationResult Complete()
287287
var writer = new PooledArrayWriter();
288288
s_planFormatter.Format(writer, OperationPlan, trace);
289289
var value = new RawJsonValue(writer.WrittenMemory);
290+
result.Extensions ??= [];
290291
result.Extensions.Add("fusion", new Dictionary<string, object?> { { "operationPlan", value } });
291292
operationResult.RegisterForCleanup(writer);
292293
}
@@ -298,7 +299,7 @@ internal IOperationResult Complete()
298299

299300
Debug.Assert(
300301
!result.Data.IsInvalidated
301-
|| (result.Errors.Count > 0),
302+
|| result.Errors?.Count > 0,
302303
"Expected to either valid data or errors");
303304

304305
_clientScope = RequestContext.CreateClientScope();

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/Pipeline/FusionMiddleware.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,18 @@ namespace HotChocolate.Fusion.Execution.Pipeline;
77
/// </summary>
88
public static class FusionMiddleware
99
{
10-
public static string OperationExecutionKey
11-
=> nameof(OperationExecutionMiddleware);
12-
1310
public static RequestMiddlewareConfiguration OperationExecution
1411
=> OperationExecutionMiddleware.Create();
1512

16-
public static string OperationPlanCacheKey
17-
=> nameof(OperationPlanCacheMiddleware);
18-
1913
public static RequestMiddlewareConfiguration OperationPlanCache
2014
=> OperationPlanCacheMiddleware.Create();
2115

22-
public static string OperationPlanKey
23-
=> nameof(OperationPlanMiddleware);
24-
2516
public static RequestMiddlewareConfiguration OperationPlan
2617
=> OperationPlanMiddleware.Create();
2718

28-
public static string OperationVariableCoercionKey
29-
=> nameof(OperationVariableCoercionMiddleware);
30-
3119
public static RequestMiddlewareConfiguration OperationVariableCoercion
3220
=> OperationVariableCoercionMiddleware.Create();
3321

34-
public static string TimeoutKey
35-
=> nameof(TimeoutMiddleware);
36-
3722
public static RequestMiddlewareConfiguration Timeout
3823
=> TimeoutMiddleware.Create();
3924
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ public bool AddPartialResults(
107107

108108
if (result.Errors?.RootErrors is { Length: > 0 } rootErrors)
109109
{
110+
_result.Errors ??= [];
110111
_result.Errors.AddRange(rootErrors);
111112
}
112113

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public bool BuildErrorResult(
115115
.Build();
116116
errorWithPath = _errorHandler.Handle(errorWithPath);
117117

118+
_result.Errors ??= [];
118119
_result.Errors.Add(errorWithPath);
119120

120121
switch (_errorHandlingMode)
@@ -191,6 +192,8 @@ private bool TryCompleteValue(
191192
}
192193

193194
error = _errorHandler.Handle(error);
195+
196+
_result.Errors ??= [];
194197
_result.Errors.Add(error);
195198

196199
if (_errorHandlingMode is ErrorHandlingMode.Propagate or ErrorHandlingMode.Halt)
@@ -217,6 +220,8 @@ private bool TryCompleteValue(
217220
.AddLocation(selection.SyntaxNodes[0].Node)
218221
.Build();
219222
errorWithPath = _errorHandler.Handle(errorWithPath);
223+
224+
_result.Errors ??= [];
220225
_result.Errors.Add(errorWithPath);
221226

222227
if (_errorHandlingMode is ErrorHandlingMode.Halt)
@@ -282,6 +287,8 @@ private bool TryCompleteList(
282287
.AddLocation(selection.SyntaxNodes[0].Node)
283288
.Build();
284289
errorWithPath = _errorHandler.Handle(errorWithPath);
290+
291+
_result.Errors ??= [];
285292
_result.Errors.Add(errorWithPath);
286293

287294
if (_errorHandlingMode is ErrorHandlingMode.Halt)

src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Text/Json/CompositeResultDocument.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,16 @@ public CompositeResultDocument(Operation operation, ulong includeFlags)
2828

2929
public CompositeResultElement Data { get; }
3030

31-
public List<IError> Errors
31+
public List<IError>? Errors
3232
{
33-
get
34-
{
35-
_errors ??= [];
36-
return _errors;
37-
}
33+
get => _errors;
34+
internal set => _errors = value;
3835
}
3936

40-
public Dictionary<string, object?> Extensions
37+
public Dictionary<string, object?>? Extensions
4138
{
42-
get
43-
{
44-
_extensions ??= [];
45-
return _extensions;
46-
}
39+
get => _extensions;
40+
internal set => _extensions = value;
4741
}
4842

4943
[MethodImpl(MethodImplOptions.AggressiveInlining)]

0 commit comments

Comments
 (0)