GQlessError & Structured Error Recovery
GraphQL APIs frequently return HTTP 200 OK even when individual resolvers fail, attaching details inside the top-level errors array. GQless wraps both network failures and GraphQL resolver errors in a single GQlessError instance so error boundaries can inspect them uniformly.
import { GQlessError } from 'gqless';
try {
const data = await resolved(() => query.viewer.email);
} catch (err) {
if (err instanceof GQlessError) {
console.error('GraphQL errors:', err.graphQLErrors);
console.error('Original network error:', err.otherError);
}
}
Best Practices for Resilient Fetchers
- Check
res.okinside yourqueryFetcherbefore callingres.json()so HTML gateway timeouts (502/504) throw clean errors instead of JSON syntax exceptions. - Avoid retrying
401or403auth failures—configure conditional retry predicates insideClientOptions. - Consult the GraphQL Errors Specification for standard
extensions.codeconventions.
Return to the Core Client API or check SSR prefetching & hydration.