hasura / hasura/graphql-engine

Actions: Return Errors as Multiple Objects as GraphQL Error Result Format

Open
#9,540 0 comments 0 reactions 0 assignees View on GitHub
k/enhancement t/gql-services
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

When implementing Hasura Actions, error objects do not support the `path` property, and cannot return more than one error as an array, such as an different error for each failed validation.

This is an issue for graphql clients because if we don't start returning errors in unexpected formats, they won't know what to do with them. Additionally, it means we'll have different formats of errors for schema stitching from Hasura Actions vs other remote schemas that do comply to the graphql spec.

### Describe the solution you'd like

Looking to return multiple error objects in the same format as Graphql spec as listed [here](https://spec.graphql.org/October2021/#sec-Errors.Error-result-format).

Hasura can extend the contract of the Actions response to include an array of `message` and `extensions`. There is an optional path attribute in the root object we would need that can indicate the particular field the error relates to. The webhook will be crafting the `path` field as well. EX:

`errors: [
{
message: 'Validation Failed',
path: ['hCreateProduct', 'name'],
extensions: {
...
}
}`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.