GQL

GQL GraphQL client integration

The GQL integration allows you to monitor all GraphQL requests that your Python application makes using the gql library. Specifically, this integration reports every 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

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

Copied
pip install --upgrade sentry-sdk

To enable the integration, add GQLIntegration() to your integrations list, like so:

Copied
import sentry_sdk
from sentry_sdk.integrations.gql import GQLIntegration

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    integrations=[
        GQLIntegration(),
    ],
    # Uncomment the following line to send GraphQL
    # queries and error information to Sentry:
    #
    # send_default_pii=True,
)

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 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.

To have Sentry record the GraphQL queries and the errors information returned by the GraphQL server, uncomment the send_default_pii=True line in the code snippet above.

Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").