---
title: "GQL"
description: "GQL GraphQL client integration"
url: https://docs.sentry.io/platforms/python/integrations/gql/
---

# GQL | Sentry for Python

The [GQL](https://gql.readthedocs.io/en/stable/) integration allows you to monitor all GraphQL requests that your Python application makes using the `gql` library. Specifically, this integration reports every [`TransportQueryError`](https://gql.readthedocs.io/en/latest/modules/transport_exceptions.html#gql.transport.exceptions.TransportQueryError) to Sentry and provides additional context including:

* The URL the request was made to
* The GraphQL query which caused the error
* The `errors` information that the GraphQL server returns

## [Install](https://docs.sentry.io/platforms/python/integrations/gql.md#install)

Make sure you have the latest version of the Sentry SDK installed:

```bash
pip install "sentry-sdk"
```

## [Configure](https://docs.sentry.io/platforms/python/integrations/gql.md#configure)

If you have the `gql` package in your dependencies, the GQL integration will be enabled automatically when you initialize the Sentry SDK.

Error Monitoring\[ ]Tracing\[ ]Profiling\[ ]Logs

```python
import sentry_sdk

sentry_sdk.init(
    dsn="___PUBLIC_DSN___",
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
    # ___PRODUCT_OPTION_START___ performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # ___PRODUCT_OPTION_END___ performance
    # ___PRODUCT_OPTION_START___ profiling
    # To collect profiles for all profile sessions,
    # set `profile_session_sample_rate` to 1.0.
    profile_session_sample_rate=1.0,
    # Profiles will be automatically collected while
    # there is an active span.
    profile_lifecycle="trace",
    # ___PRODUCT_OPTION_END___ profiling
    # ___PRODUCT_OPTION_START___ logs

    # Enable logs to be sent to Sentry
    enable_logs=True,
    # ___PRODUCT_OPTION_END___ logs
)
```

## [Data Privacy and the GQL Integration](https://docs.sentry.io/platforms/python/integrations/gql.md#data-privacy-and-the-gql-integration)

To ensure data privacy, the SDK avoids sending any information that may potentially contain personally identifiable information (PII) by default. See the docs for the [`send_default_pii` flag](https://docs.sentry.io/platforms/python/configuration/options.md#send-default-pii) for more information.

For the GQL integration, this policy means that the SDK **doesn't send** the GraphQL queries and the `errors` information that the GraphQL server returns, unless you override the default configuration via the `send_default_pii` flag.

Before enabling the `send_default_pii` flag, ensure you've configured Sentry's [sensitive data scrubbing](https://docs.sentry.io/platforms/python/data-management/sensitive-data.md) tools to scrub all PII.

To have Sentry record the GraphQL queries and the `errors` information returned by the GraphQL server, add the following to your SDK init:

```python
sentry_sdk.init(
    # ...
    # Add data like request headers and IP for users, if applicable;
    # see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
    send_default_pii=True,
)
```
