Improve `composeClient.executeQuery` validation error format

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.

FYI @paul - maybe there’s something we can do in the client-side tooling to make the errors more obvoius and easy to understand?

It’s not really something we can address purely client-side, the first step would be for the server to return a 400 error with the validation details, so we could at least approximately associate them with the source query.

isn’t that what we do today? What would need to be different from the error response we return today, that leo pasted above?

The error is returned with a HTTP status code 500, not 400, and the validation errors are returned as a single string rather than the details provided by Ajv in API Reference | Ajv JSON schema validator

Okay thanks. @avi to track the feature request