Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log graphql error #15544

Merged
merged 16 commits into from
Mar 21, 2024
Merged
Changes from 13 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 @@ -18,6 +18,7 @@
using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using OrchardCore.Apis.GraphQL.Queries;
using OrchardCore.Apis.GraphQL.ValidationRules;
Expand All @@ -27,6 +28,7 @@ namespace OrchardCore.Apis.GraphQL
{
public class GraphQLMiddleware : IMiddleware
{
private readonly ILogger _logger;
private readonly GraphQLSettings _settings;
private readonly IGraphQLSerializer _serializer;
private readonly IDocumentExecuter _executer;
Expand All @@ -37,11 +39,13 @@ public class GraphQLMiddleware : IMiddleware
public GraphQLMiddleware(
IOptions<GraphQLSettings> settingsOption,
IDocumentExecuter executer,
IGraphQLSerializer serializer)
IGraphQLSerializer serializer,
ILogger<GraphQLMiddleware> logger)
{
_settings = settingsOption.Value;
_executer = executer;
_serializer = serializer;
_logger = logger;
}
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
Expand Down Expand Up @@ -122,7 +126,10 @@ private async Task ExecuteAsync(HttpContext context)
catch (Exception e)
{
await _serializer.WriteErrorAsync(context, "An error occurred while processing the GraphQL query", e);
return;

_logger.LogError(e, "An error occurred while processing the GraphQL query.");
hishamco marked this conversation as resolved.
Show resolved Hide resolved
hishamco marked this conversation as resolved.
Show resolved Hide resolved

hishamco marked this conversation as resolved.
Show resolved Hide resolved
await Task.CompletedTask;
Piedone marked this conversation as resolved.
Show resolved Hide resolved
hishamco marked this conversation as resolved.
Show resolved Hide resolved
}

var queryToExecute = request.Query;
Expand Down
Loading