I have a question, how the response to the query / mutation of GraphQL should look in each of the following cases:
- There is a result, no errors
- Something went wrong, one or more errors
- There is a result and some errors
I'm not sure that the latter is possible, but I seem to remember something that might happen. For instance. in the case of multiple mutations, say two, where each mutation is processed sequentially. I think that case number 3 above can happen if the first mutation is in order, but the error occurs during the execution of the second, but I'm not sure.
In any case, what should the answers look like? How below? (Examples in JSON, where each corresponds to the cases previously). Or are there other ways that are more idiomatic? Perhaps Relay provides some guidance on how this should look? I could not find any good resources for this.
1
{
"data": {
...
}
}
2:
{
"errors": [
{
...
},
...
]
}
3:
{
"data": {
...
},
"errors": [
{
...
},
...
]
}
Thank.
source
share