Every mutation is an operation that modifies data. So it would be great to have an indicator that shows whether operation was successfully or not. One common pattern in REST-world is to use HTTP status code. In GraphQL we can use a similar approach.
GraphQL doesn't depend on protocol - it can be used with http, WebSocket, telnet, ssh and other. One GraphQL-mutation can contain multiple operations that can be completed with different statuses and have different errors. Developers that came from REST-world suffer absence of HTTP status code, and someone even try to reinvent it in GraphQL-server. So why not to add status
field in your mutation response then?!
type CreatePersonPayload {
record: Person
+ status: CreatePersonStatus! # fail, success, etc. Or 201, 403, 404 etc.
# ... any other fields you like
}
Field status
could be Enum
with the limited range of possible values. This Enum could be unique per mutation / business entity or shared across application - it depends.