✨ [RUM-13680] Add support for GraphQL GET requests with query params (APQ)#4125
Open
rgaignault wants to merge 5 commits intomainfrom
Open
✨ [RUM-13680] Add support for GraphQL GET requests with query params (APQ)#4125rgaignault wants to merge 5 commits intomainfrom
rgaignault wants to merge 5 commits intomainfrom
Conversation
Bundles Sizes Evolution
🚀 CPU Performance
🧠 Memory Performance
|
bcaudan
reviewed
Jan 28, 2026
| graphQlConfig: GraphQlUrlOption | ||
| ): GraphQlMetadata | undefined { | ||
| const metadata = extractGraphQlRequestMetadata(request.requestBody, graphQlConfig.trackPayload) | ||
| const metadata = extractGraphQlRequestMetadata(request.requestBody, graphQlConfig.trackPayload, request.url) |
Collaborator
There was a problem hiding this comment.
💬 suggestion: what about passing directly the full request to this method? instead of passing every needed request attributes
Comment on lines
88
to
93
| if (requestBody && typeof requestBody === 'string') { | ||
| return extractFromBody(requestBody, trackPayload) | ||
| } | ||
| // Fallback for persisted queries | ||
| if (url) { | ||
| return extractFromUrlQueryParams(url, trackPayload) |
Collaborator
There was a problem hiding this comment.
💬 suggestion: Instead of having the extract methods that call the build method internally, we could:
- rename the build method as sanitize since it seems to be the intent
- call the sanitize method from extractGraphQlRequestMetadata , so the specific extract methods would be more focused and the higher level method would manage the execution flow
- move the parseVariableParams to the sanitize function as well
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage 🔗 Commit SHA: 243664a | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
BenoitZugmeyer
approved these changes
Feb 9, 2026
Comment on lines
160
to
167
| if (rawMetadata.variables) { | ||
| try { | ||
| // Parse to validate it's valid JSON, then keep the string | ||
| JSON.parse(rawMetadata.variables) | ||
| variables = rawMetadata.variables | ||
| } catch { | ||
| // Invalid JSON in variables, ignore | ||
| } |
Member
There was a problem hiding this comment.
suggestion: do we need to validate this? Maybe we can just trust that it is correctly encoded?
If we still want this validation, I suggest to:
- move it to
extractFromUrlQueryParams, since it's only useful in this case - maybe introduce a
tryJsonParsehelper, because we already have a few usages in this file. Ex:
function tryJsonParse<T = unknown>(text: string): T | undefined {
try { return JSON.parse(text) } catch {}
}Then
let graphqlBody: {
query?: string
operationName?: string
variables?: unknown
}
try {
graphqlBody = JSON.parse(requestBody)
} catch {
// Not valid JSON
return
}
if (!graphqlBody) {
return
}
// becomes
const graphqlBody = tryJsonParse<{
query?: string
operationName?: string
variables?: unknown
}>(requestBody)
if (!graphqlBody) {
return
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When using Apollo's Automatic Persisted Queries (APQ) with useGETForHashedQueries: true, GraphQL requests are sent as GET instead of POST. In this case, operationName, variables, and query are passed as URL query params instead of request body.
The extractGraphQlRequestMetadata function only inspects the request body, so it misses GraphQL metadata for GET requests in this particular context. As it was requested by a customer we could support it by parsing the url.
Changes
We could support it by parsing the url.
FR:#4063
Test instructions
Checklist