Skip to content

feat(graphql): [Data Collection 4] Apply GraphQL policies - #5800

Draft
adinauer wants to merge 8 commits into
feat/data-collection-resolverfrom
feat/data-collection-graphql
Draft

feat(graphql): [Data Collection 4] Apply GraphQL policies#5800
adinauer wants to merge 8 commits into
feat/data-collection-resolverfrom
feat/data-collection-graphql

Conversation

@adinauer

@adinauer adinauer commented Jul 21, 2026

Copy link
Copy Markdown
Member

PR Stack (Data Collection)


📜 Description

Apply Data Collection policies to GraphQL document and variable capture across GraphQL Java and Apollo 2, 3, and 4 integrations.

The integrations independently filter GraphQL documents and variables while retaining operation metadata. Legacy sendDefaultPii, request-size, and integration-specific always-collect behavior remain unchanged when Data Collection is absent.

💡 Motivation and Context

GraphQL documents and variables can contain customer data. The new namespace provides granular control without forcing integrations to interpret legacy options themselves.

Refs #5666

💚 How did you test it?

  • ./gradlew spotlessApply apiDump
  • GraphQL core and Apollo 2/3/4 module tests
  • ./gradlew apiCheck

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Apply the remaining Data Collection categories to database and HTTP integration paths.

#skip-changelog

⚠️ Merge this PR using a merge commit (not squash). Only the collection branch is squash-merged into main.

Control GraphQL documents and variables through the new Data Collection policies across GraphQL and Apollo integrations. Preserve sendDefaultPii and maxRequestBodySize behavior when Data Collection is absent.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against c7a9cbb

@adinauer adinauer mentioned this pull request Jul 21, 2026
8 tasks
@sentry

sentry Bot commented Jul 21, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.48.0 (1) release

⚙️ sentry-android Build Distribution Settings

Bring the queue option removal and preceding stack updates into this layer.
try {
it.writeTo(buffer)
data = buffer.readUtf8()
data = GraphqlUtils.filterRequestBody(buffer.readUtf8(), scopes.options)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GraphQL/Apollo also allow Http.Get for queries (https://graphql.org/learn/serving-over-http/#get-request-and-parameters) so we might need to filter that too, not just the request body.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory customers can just use:

dataCollection.setUrlQueryParams(
       KeyValueCollectionBehavior.denyList("query", "variables"));

It looks like other SDKs also aren't using the graphql options on GET params.
We can just mention this in docs.

Comment thread sentry/src/main/java/io/sentry/util/GraphqlUtils.java Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


This PR will not appear in the changelog.


🤖 This preview updates automatically when you update the PR.

adinauer and others added 3 commits August 31, 2026 06:21
Add focused coverage for parsing a single GraphQL request object and
independently removing document and variable content while preserving
operation metadata and allowed fields.

Refs #5666
Co-Authored-By: Claude <noreply@anthropic.com>
Apply document and variable collection policies to every operation in a
batched GraphQL request. Fail closed when a batch contains non-object
entries instead of attaching partially filtered content.

Refs #5666
Co-Authored-By: Claude <noreply@anthropic.com>
Verify GraphQL request filtering fails closed when a batch contains a non-object entry.

Refs #5666

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 360.13 ms 435.59 ms 75.46 ms
Size 0 B 0 B 0 B

Previous results on branch: feat/data-collection-graphql

Startup times

Revision Plain With Sentry Diff
715de33 312.83 ms 366.16 ms 53.33 ms

App size

Revision Plain With Sentry Diff
715de33 0 B 0 B 0 B

…n-graphql

# Conflicts:
#	sentry/src/test/java/io/sentry/DataCollectionResolverTest.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants