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

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

Configuration should happen as early as possible in your application's lifecycle.

Copied
import sentry_sdk

sentry_sdk.init(
    dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
    # Set traces_sample_rate to 1.0 to capture 100%
    # of transactions for tracing.
    traces_sample_rate=1.0,
    # Set profiles_sample_rate to 1.0 to profile 100%
    # of sampled transactions.
    # We recommend adjusting this value in production.
    profiles_sample_rate=1.0,
)

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, add the following to your SDK init:

Copied
sentry_sdk.init(
    # ...
    send_default_pii=True,
)
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").