Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
GraphQL Core 0.0.6
-
None
Description
Problem:
Currently, the DefaultQueryExecutor.execute method does not let GraphQL query execution errors pass on to result. After executing GraphQL query, any errors are accumulated as strings and wrapped into an exception [0]. This causes errors to be omitted from GraphQL response, as the result is never returned [1].
As a consequence, The GraphQL client receives a cryptic error response, which is
- not conformed to GraphQL specs
- not useful, as it does not give a hint what actually went wrong
Proposed solution:
An exception in such a case should not be thrown, rather errors should be returned as part of the GraphQL result, conforming to GraphQL specs [2].
Example:
Query { articles { items { _path author_DOES_NOT_EXIST } } }
(Note: author_DOES_NOT_EXIST field name is intentionally wrong.)
Current response:
{ "message": "Failed to execute 'text' on 'Response': body stream already read", "stack": "TypeError: Failed to execute 'text' on 'Response': body stream already read\n at https://<host-url>/graphiql.html:64:29" }
Expected response:
{ "errors": [ { "message": "Validation error of type FieldUndefined: Field 'author_DOES_NOT_EXIST' in type 'ArticleModel' is undefined @ 'articles/items/author_DOES_NOT_EXIST'", "locations": [ { "line": 5, "column": 7 } ], "extensions": { "classification": "ValidationError" } } ] }
Which is more meaningful, and conformed to GraphQL errors scpecification [2].
Attachments
Issue Links
- links to