It is important to handle errors and when possible, report these errors back to your users for information. Using GraphQL brings a new set of possible errors from the actual GraphQL response itself. With that in mind, here are a few different types of errors:

GraphQL Errors

The query fails due to GraphQL internal validation (syntax, schema logic, etc.). These type of error should not be displayed to final users and should be fixed in your query. The response contains a list of errors in the following format:

{
  "errors": [
    {
      "code": 400,
      "message": "Cannot query field \"amount\" on type \"User\".",
      "category": "graphql",
      "locations": [
        {
          "line": 3,
          "column": 5
        }
      ]
    }
  ]
}

Server Errors

Something is broken. This is usually a temporary error, for example in a high load situation or if an endpoint is temporarily having issues. The error code is always 500 if the error persists during some time, contact-us and provide us the tracking_id.

{
  "errors": [
    {
      "code": 500,
      "tracking_id": "AD1AD4F8-ADA2-DE84-845D-3CA7E401",
      "message": "Internal Server Error",
      "category": "internal"
    }
  ]
}

Validation Errors

The error 422 refer to invalid submitted data, the user can update the form and try submitting the transaction again. The validation error always contains a key called constraintViolations with some details about the validation error.

{
  "errors": [
    {
      "code": 422,
      "tracking_id": "AB083135-A2B1-5D80-F6DF-456EB938",
      "message": "Unprocessable Entity",
      "category": "user",
      "constraintViolations": [
        {
          "code": "c1051bb4-d103-4f74-8988-acbcafc7fdc3",
          "message": "This value should not be blank.",
          "messageTemplate": "This value should not be blank.",
          "propertyPath": "inputs.accountNumber",
          "parameters": {
            "{{ value }}": "\"\""
          },
          "invalidValue": ""
        }
      ]
    }
  ],
  "data": {
    "transactions": {
      "submit": {
        "transaction": null
      }
    }
  }
}

Others Errors

These type of errors happen when the server accept the operation but a error happen processing it. All these errors are documented in error codes.

{
  "errors": [
    {
      "code": 1101,
      "message": "Insufficient Funds",
      "category": "user"
    }
  ]
}