Skip to content

Define extra properties to errors #912

@kbariotis

Description

@kbariotis

From the specs

GraphQL servers may provide additional entries to error as they choose to produce more helpful or machine‐readable errors, however future versions of the spec may describe additional entries to errors.

As far as I understand, we should be able to define custom properties to errors that are being exposed to the GraphQL response. Like this:

{
  "errors": [
    {
      "message": "Name for character with ID 1002 could not be fetched.",
+    "type": "NOT_FOUND",
      "locations": [ { "line": 6, "column": 7 } ],
      "path": [ "hero", "heroFriends", 1, "name" ]
    }
  ],
  "data": {
    "hero": {
      "name": "R2-D2",
      "heroFriends": [
        {
          "id": "1000",
          "name": "Luke Skywalker"
        },
        null,
        {
          "id": "1003",
          "name": "Leia Organa"
        }
      ]
    }
  }
}

Is this currently possible? Should we consider adding it to this library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions