Tuesday, 23 May 2017

how to return an array of errors with graphQL

How can I return multiple error messages like this ?

"errors": [
  {
    "message": "first error",
    "locations": [
      {
        "line": 2,
        "column": 3
      }
    ],
    "path": [
      "somePath"
    ]
  },
  {
    "message": "second error",
    "locations": [
      {
        "line": 8,
        "column": 9
      }
    ],
    "path": [
      "somePath"
    ]
  },
]

On my server, if I do throw('an error'), it returns.

"errors": [
      {
        "message": "an error",
        "locations": [
          {
          }
        ],
        "path": [
          "somePath"
        ]
      }]

I would like to return an array of all the errors in the query. How can I add mutlpiple errors to the errors array ?



via Lev

No comments:

Post a Comment