This module provides HTTP tracing and failed GraphQL request reporting for Apollo Kotlin 5.
Please consult the documentation on how to install and use this integration in the Sentry Docs for Android or Java.
Add io.sentry:sentry-apollo-5 and install the integration while building the Apollo client:
val apolloClient =
ApolloClient.Builder()
.serverUrl("https://example.com/graphql")
.sentryTracing()
.build()The builder extension installs the Apollo interceptor before the cache and the Sentry HTTP interceptor.
Apollo rejects builder HTTP interceptors when a custom NetworkTransport is configured, so do not use sentryTracing() in that case. Add SentryApollo5Interceptor to the client builder and SentryApollo5HttpInterceptor to the custom transport manually.
Operation metadata is propagated between these interceptors through Apollo's execution context. Apollo's default HTTP request composer copies this context automatically. A custom HttpRequestComposer must copy it explicitly when building the HTTP request:
HttpRequest.Builder(method, url)
.addExecutionContext(apolloRequest.executionContext)
.build()An entirely custom NetworkTransport must expose the metadata to SentryApollo5HttpInterceptor in the same way.
- Failed GraphQL request detection matches the raw JSON response body for an
errorsfield. - Failed GraphQL request detection is skipped for streaming responses (
multipart/mixed,text/event-stream) to avoid buffering the body; spans and breadcrumbs are still recorded for them. - WebSocket subscriptions are not instrumented.
- Batching behavior depends on HTTP interceptor ordering.
- Normalized-cache hits do not create HTTP spans.