If the Upwork server fails while processing a GraphQL request, the system sends an error array response to the client.
Errors in GraphQL are handled differently from REST. While REST endpoints return HTTP status codes in the error response, for example, 400 - Bad Request in case of malformed syntax, GraphQL always returns a 200 - OK status code, regardless of whether the operation succeeded or failed. Understanding how to decode error responses in GraphQL is crucial to troubleshooting potential operation failures.
Decoding error responses
GraphQL error arrays list all the errors that occurred while processing the API request. As the generic status code in GraphQL is not intuitive, you must review the body of the error response to further understand the correct status of the operation. In particular, the following will help you troubleshoot any problems or guide you on what to do next:
- Message: The error message that helps you understand if the operation succeeded or failed. For example, Validation error of type MissingFieldArgument.
- Locations: The exact location in the API request query that results in the error. For example, the line and column parameters in the response.
- Extensions: The type of error. For example, ValidationError.
Learn more through the developers’ API documentation.