Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ public void ReportError(Exception exception, Action<ErrorBuilder>? configure = n

if (exception is GraphQLException ex)
{
foreach (var error in ex.Errors)
if (ex.Errors.Count > 0)
{
ReportError(error);
ReportError(ex.Errors[0]);
}
}
else if (exception is AggregateException aggregateException)
{
foreach (var innerException in aggregateException.InnerExceptions)
if (aggregateException.InnerExceptions.Count > 0)
{
ReportError(innerException);
ReportError(aggregateException.InnerExceptions[0]);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Microsoft.Extensions.DependencyInjection;

namespace HotChocolate.Execution.Errors;

public class Issue7074ReproTests
{
[Fact]
public async Task Aggregate_GraphQLException_Produces_Only_One_Field_Error()
{
var executor = await new ServiceCollection()
.AddGraphQL()
.AddQueryType<Query>()
.BuildRequestExecutorAsync();

var result = await executor.ExecuteAsync("{ test }");
var json = result.ToJson();

Assert.Contains("Test1", json, StringComparison.Ordinal);
Assert.DoesNotContain("Test2", json, StringComparison.Ordinal);
}

public class Query
{
public string Test()
=> throw new AggregateException(
new GraphQLException("Test1"),
new GraphQLException("Test2"));
}
}
Loading