When the executeQuery
function is called with a data validation error, it’s hard to parse and show some feedback to the user.
Currently the message returned is "HTTP request to 'http://localhost:7007/api/v0/streams' failed with status 'Internal Server Error': {\"error\":\"Validation Error: data/title must NOT have fewer than 10 characters\"}"
.
This code:
const data = await composeClient.executeQuery(`...`);
console.log(data);
Produces:
{
"errors": [
{
"message": "HTTP request to 'http://localhost:7007/api/v0/streams' failed with status 'Internal Server Error': {\"error\":\"Validation Error: data/title must NOT have fewer than 10 characters\"}",
"locations": [
{
"line": 3,
"column": 9
}
],
"path": [
"createPost"
]
}
],
"data": {
"createPost": null
}
}
Just returning the JSON or other would make it easier to catch and provide some context to the user on what went wrong.