Description
Hi,
I've noticed in the main Controller of the bundle, in case of JSON syntax error, a RuntimeException in thrown, which result to a 500 HTTP return code by Symfony with an "Internal Server Error" HTML response.
graphqlite-bundle/Controller/GraphQLiteController.php
Lines 84 to 89 in 9fc3c79
In my point of view, both cases should return a JSON response formatted as GraphQL response with errors, with a 400 HTTP code like :
{
"errors": [
{
"message": "Invalid JSON received in POST body",
"extensions": {
"reason": "Syntax error"
}
}
]
}
or
{
"errors": [
{
"message": "Invalid JSON received in POST body",
"extensions": {
"reason": "Expecting associative array from request, got string"
}
}
]
}
The trick is that we are outside of the GraphQL Server context, so throwing a GraphQLException here doesn't have the desired effect. But the solution could be to create an GraphQLException Listener then create a JsonResponse from an ExecutionResult+Error from the GraphQLException.
What do you think ?
Already tried it so I can work on it and submit a PR.