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

# GQL 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"
```

*Other available variations of the above snippet: uv*

## [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

```python
import sentry_sdk

sentry_sdk.init(
    dsn="https://<key>@o<orgId>.ingest.sentry.io/<projectId>",
    # Check https://docs.sentry.io/platforms/python/data-management/data-collected/ to configure what data is collected
    data_collection={
        "user_info": True,
    },
    # ___PRODUCT_OPTION_START___ performance
    # Set traces_sample_rate to 1.0 to capture 100%
    # of service spans 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
)
```

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

By default, the SDK records the GraphQL queries and the `errors` information that the GraphQL server returns. To control this, use the `graphql` key of the [`data_collection`](https://docs.sentry.io/platforms/python/configuration/options.md#data_collection) option in your SDK init. The `document` key controls the queries and the `errors` information, and the `variables` key controls the query variables:

```python
sentry_sdk.init(
    # ...
    data_collection={
        "graphql": {"document": True, "variables": True},
    },
)
```

These are the defaults. See [Data Collected](https://docs.sentry.io/platforms/python/data-management/data-collected.md) for all available keys.

In SDK versions prior to `3.0`, this data isn't sent by default. To send it, pass a `data_collection` dictionary as shown above, or set the `send_default_pii` option to `True`. Since `send_default_pii` is a global SDK option, setting it to `True` affects all integrations, so make sure to [scrub sensitive data](https://docs.sentry.io/platforms/python/data-management/sensitive-data.md) from events first.

---

Find other pages: [Sitemap](https://docs.sentry.io/sitemap.md) lists every page with a one-line summary, and [llms.txt](https://docs.sentry.io/llms.txt) gives an overview with guidance for agents.
