---
title: "GraphQL Client Errors"
description: "This feature captures graphql-client errors and reports them to Sentry"
url: https://docs.sentry.io/platforms/dotnet/guides/entityframework/configuration/graphql-client-errors/
---

# GraphQL Client Errors | Sentry for Entity Framework

Once enabled, this feature captures and reports GraphQL over HTTP errors when you use the [graphql-client](https://github.com/graphql-dotnet/graphql-client) library. In addition to basic information about the HTTP request and response, the error event can also capture details of the GraphQL request such as: operation name, type, query, and response.

To capture GraphQL over HTTP errors, you have to enable `SentryOptions.CaptureFailedRequests` and configure `GraphQLHttpClientOptions.HttpMessageHandler` to use `SentryGraphQLHttpMessageHandler`.

1. Enable the feature in Sentry:

```csharp
// Add this to the SDK initialization callback
options.CaptureFailedRequests = true;
```

2. Configure Sentry instrumentation on the graphql-client:

```csharp
var graphClient = new GraphQLHttpClient(
    options =>
    {
        options.EndPoint = new Uri("http://your.app.server/graphql");
        options.HttpMessageHandler = new SentryGraphQLHttpMessageHandler(); // <-- Configure GraphQL use Sentry Message Handler
    },
    new SystemTextJsonSerializer()
    );
```

By default, Sentry will capture GraphQL over HTTP client errors for requests to any GraphQL endpoint. You can change this behavior by updating the `FailedRequestTargets` option with either regular expressions or plain strings. Plain strings don't have to be full matches, meaning the URL of a request is matched when it contains a substring provided through the option:

```csharp
options.FailedRequestTargets.Add("foo");      // substring
options.FailedRequestTargets.Add("foo.*bar"); // regex
```

When the `SendDefaultPii` option is enabled, error events may contain PII data such as `Headers`, `Cookies`, and the GraphQL request `query`. To scrub this data before it's sent, see [Scrubbing Sensitive Data](https://docs.sentry.io/platforms/dotnet/data-management/sensitive-data.md).

These events are searchable. You can set alerts for them using properties like the `http.url` and `http.status_code`. Read our [Searchable Properties](https://docs.sentry.io/concepts/search/searchable-properties.md) docs to learn more.

## [Customize or Drop an Error Event](https://docs.sentry.io/platforms/dotnet/guides/entityframework/configuration/graphql-client-errors.md#customize-or-drop-an-error-event)

Any captured error event can be customized or dropped in the `SetBeforeSend` callback like this:

```csharp
options.SetBeforeSend((@event, hint) =>
{
    return @event.Breadcrumbs.Any(b => b.Type == "graphql" && b?.Data?["operation_name"] == "fakeMutation")
        ? null  // Ignore errors for fakeMutations
        : @event;
});
```
