Skip to content

Conversation

@barboraplasovska
Copy link
Contributor

@barboraplasovska barboraplasovska commented Oct 29, 2025

What and why?

GraphQL APIs follow a different error model than REST APIs, they return HTTP 200 OK status codes even when operations fail with errors included in the response body under an errors key. Without parsing the response body, these errors would go unnoticed in RUM monitoring.
This PR adds support for automatically detecting, parsing, and reporting GraphQL errors in RUM resource events. When a GraphQL request completes with errors in the response, the SDK now captures and includes them in the resource event.

How?

When a request completes with a JSON response, we check for the presence of an errors key. If found, the response body is passed along to the resource scope where it's decoded according to the GraphQL spec and populated into the resource event's graphql.errors array and graphql.errorCount fields. (cc PR on rum_events_format).

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes
  • Add Objective-C interface for public APIs (see our guidelines (internal) and run make api-surface)

@barboraplasovska barboraplasovska self-assigned this Oct 29, 2025
@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-12441/graphql-errors branch 6 times, most recently from 2917f4b to 85a1acc Compare October 30, 2025 16:25
@datadog-datadog-prod-us1

This comment has been minimized.

@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-12441/graphql-errors branch 4 times, most recently from 0381249 to 881b167 Compare October 31, 2025 15:41
@barboraplasovska barboraplasovska force-pushed the bplasovska/RUM-12441/graphql-errors branch from 35f7626 to 3fc640f Compare November 3, 2025 09:19
Comment on lines +12 to +25
// Extension to make Path conform to Equatable for testing
extension RUMResourceEvent.Resource.Graphql.Errors.Path: Equatable {
public static func == (lhs: RUMResourceEvent.Resource.Graphql.Errors.Path, rhs: RUMResourceEvent.Resource.Graphql.Errors.Path) -> Bool {
switch (lhs, rhs) {
case (.string(let lhsValue), .string(let rhsValue)):
return lhsValue == rhsValue
case (.integer(let lhsValue), .integer(let rhsValue)):
return lhsValue == rhsValue
default:
return false
}
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this extension to be able to do XCTAssertEqual on a Path. Not sure if there is a better way to make this testable.

@barboraplasovska barboraplasovska marked this pull request as ready for review November 3, 2025 09:23
@barboraplasovska barboraplasovska requested review from a team as code owners November 3, 2025 09:24
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.

3 participants