magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

Cannot return several errors for one GraphQL request #970

Closed kisroman closed 5 years ago

kisroman commented 5 years ago

Now there is no ability to throw two errors, we can only implode it in one string(as in https://github.com/magento/graphql-ce/issues/961 in method getAddressErrors()).

If you create exception GraphQlInputException it has method addError(), so you can add additional errors, but it doesn't work.See screenshot, I added two errors with method addError(), but it returns only one.

Actual result: Only one last error is returned.

Screen Shot 2019-09-27 at 13 42 29

Expected result:

{
  "errors": [
    {
      "message": "First error.",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    },
    {
      "message": "Second error.",
      "extensions": {
        "category": "graphql"
      },
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ]
    }
  ]
}
lenaorobei commented 5 years ago

See related webonyx discussion https://github.com/webonyx/graphql-php/issues/207

TomashKhamlai commented 5 years ago

Related topics: #416, #625,

lenaorobei commented 5 years ago

AC: