Skip Navigation

GraphQL Responses Treat [] as Having Errors

CodeGraphQL

From the GraphQL Specification

The errors entry in the response is a non‐empty list of errors, where each error is a map.



If no errors were encountered during the requested operation, the errors entry should not be present in the result.

That means a response of

{
"data": {
"your_response": "..."
},
"errors": []
}

Will be considered an error by clients and will fail an otherwise successful response. You'll either need to delete the key from the object or exclude it with clever use of the spread ... operator.