Skip to content
Closed
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
22 changes: 20 additions & 2 deletions src/Transports.AspNetCore/GraphQLHttpMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,16 @@ await WriteErrorResponseAsync(httpResponse, writer, cancellationToken,
{
var stopwatch = ValueStopwatch.StartNew();
await RequestExecutingAsync(gqlRequest);
var result = await ExecuteRequestAsync(gqlRequest, userContext, executer, context.RequestServices, cancellationToken);
ExecutionResult result;
try
{
result = await ExecuteRequestAsync(gqlRequest, userContext, executer, context.RequestServices, cancellationToken);
}
catch (InvalidOperationException e) //TODO: find a better way for sorting 4xx from 5xx
{
await WriteErrorResponseAsync(httpResponse, writer, cancellationToken, e.Message);
return;
}

await RequestExecutedAsync(new GraphQLRequestExecutionResult(gqlRequest, result, stopwatch.Elapsed));

Expand All @@ -150,7 +159,16 @@ await WriteErrorResponseAsync(httpResponse, writer, cancellationToken,

var stopwatch = ValueStopwatch.StartNew();
await RequestExecutingAsync(gqlRequestInBatch, i);
var result = await ExecuteRequestAsync(gqlRequestInBatch, userContext, executer, context.RequestServices, cancellationToken);
ExecutionResult result;
try
{
result = await ExecuteRequestAsync(gqlRequestInBatch, userContext, executer, context.RequestServices, cancellationToken);
}
catch (InvalidOperationException e) //TODO: find a better way for sorting 4xx from 5xx
{
await WriteErrorResponseAsync(httpResponse, writer, cancellationToken, e.Message);
return;
}

await RequestExecutedAsync(new GraphQLRequestExecutionResult(gqlRequestInBatch, result, stopwatch.Elapsed, i));

Expand Down