Skip to content

Add response error graphql properties#308

Merged
rgaignault merged 3 commits into
masterfrom
romanG/graphql-error-tracking-schema
Oct 15, 2025
Merged

Add response error graphql properties#308
rgaignault merged 3 commits into
masterfrom
romanG/graphql-error-tracking-schema

Conversation

@rgaignault

@rgaignault rgaignault commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

Add new properties for the following support for graphql response tracking.

Note : The code property is not native but taken from the extension field and move at the top level. As we would like to query directly : @resource.[…].errors.code:xxx. It is present in the spec as a field in the extension part, so it could be manually added by the customers but also some libraries such as Apollo directly provide it in the response. (see Documentation)

See the spec for more informations about the graphql response format : GraphQL Spec

@rgaignault
rgaignault requested review from a team as code owners October 1, 2025 13:23
Comment thread lib/cjs/generated/rum.d.ts Outdated
Comment thread schemas/rum/resource-schema.json Outdated
},
"code": {
"type": "string",
"description": "Error code from GraphQL extensions",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💬 suggestion: IMO, mentioning GraphQL extensions can be a bit confusing here because it requires to be aware of this concept of the GraphQL spec, and it could easily be misunderstood with the extension concept we have at SDK level.

I think we could:

  • Not mention it at all, "Error code"
  • Not mention GraphQL extension, "Error code (used by some providers)"

@rgaignault rgaignault Oct 14, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sounds good ! I would prefer the second one as it is not always present. (to inform customers why it's not there)

Comment thread samples/rum-events/resource-graphql.json Outdated
bcaudan
bcaudan previously approved these changes Oct 14, 2025

@bcaudan bcaudan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@barboraplasovska barboraplasovska left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@satween
satween self-requested a review October 15, 2025 13:57
@rgaignault
rgaignault merged commit fe2d362 into master Oct 15, 2025
9 checks passed
@rgaignault
rgaignault deleted the romanG/graphql-error-tracking-schema branch October 15, 2025 14:49
"path": {
"type": "array",
"description": "Path to the field that caused the error",
"items": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rgaignault Question.

What does this path mean? Is it ok that it is an array of either strings or numbers? Are you sure everything is correct here?

Asking because for Android our json parser generator fails to process this and I want to know if I need to fix it (add support of oneOf(primitive types)).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hey @aleksandr-gringauz ! Based on the spec, that's what I have : https://github.com/graphql/graphql-spec/blob/main/spec/Section%207%20--%20Response.md.

The value for a response path must be a list of path segments. Path segments that represent field response name must be strings, and path segments that represent list indices must be 0-indexed integers.

Also based on the examples it's either integer or string. Do you see an other way of declaring this ?

@aleksandr-gringauz aleksandr-gringauz Oct 23, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the reply @rgaignault!

Do you see an other way of declaring this ?

For me the following option will work. Checked it in dd-sdk-android.

"path": {
  "type": "array",
  "description": "Path to the field that caused the error",
  "items": {
    "oneOf": [
      {
        "type": "object",
        "title": "String",
        "required": ["segment"],
        "properties": {
          "segment": {
            "type": "string"
          }
        }
      },
      {
        "type": "object",
        "title": "Integer",
        "required": ["segment"],
        "properties": {
          "segment": {
            "type": "integer"
          }
        }
      }
    ]
  },
  "readOnly": true
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The problem with Kotlin is that we don't have String | Integer like typescript. We only have sealed classes, for example:

sealed interface Path {
    data class String(val segment: String): Path
    data class Integer(val segment: Int): Path
}

If I were to try to implement String | Integer I would have to generate something like:

sealed interface StringOrInt {
    data class String(val segment: String): StringOrInt
    data class Integer(val segment: Int): StringOrInt
}

And if oneOf(string|int) occurs multiple times in the schema, I would have to make different StringOrInt for them or somehow reuse a common one.

It all requires some work on the generator which I would like to avoid if possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed with @maxep about how they do on iOS. I might implement similar solution on Android, but need more time to think.

For now, no action is needed from your side. Thanks!

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.

6 participants