Render available data while surfacing execution errors
Client response handling
GraphQL · Class
GraphQL reports problems in a response-level errors entry. Request errors stop execution and omit data, while field errors can be returned with partial data.
GraphQL represents raised problems in the response's errors entry. Request errors happen before execution and omit data, while field errors occur during execution and can coexist with partial data; each error includes a developer-facing message, and may include locations or a path.
A GraphQL response can include an errors entry containing error information; it may also include data for a partial response.
const result = {
data: { user: null },
errors: [{
message: "User not found",
path: ["user"]
}]
};
if (result.errors) {
for (const error of result.errors) console.error(error.message);
}A client can inspect the errors array while still using any partial data returned by the operation.
Client response handling
Query diagnostics
Resolver monitoring
GraphQL responses can contain data, errors, or both. Request errors occur before execution and therefore exclude data, while execution-time field errors may produce partial data alongside errors.
Follow-up: How should a client distinguish a malformed operation from a resolver failure? A missing data field indicates a request-stage problem; data together with errors indicates an execution-stage problem.
The errors entry contains information about raised errors, and each error includes a message intended to help developers understand the problem. A location may identify where the issue occurred in the document.
Follow-up: What additional information can identify an execution failure? The path can indicate the response field where the failure occurred.
A GraphQL response must include at least one of data or errors. If execution produces a field error, GraphQL can continue resolving other fields and return a partial response.
Follow-up: What happens when a non-null field cannot produce a value? Nullability propagation can make a containing field, or larger portion of the response, null while the error remains reported.
dataerrorsextensionsrequest errorsfield errorspartial responselocationspath