toeverything/AFFiNE · error · GraphQLError
${firstError.message}
Error message
${firstError.message} What it means
gqlFetch extracts result.errors from the GraphQL JSON response and throws a GraphQLError with the first error's message, surfacing server-side execution errors (auth failures, bad input) as exceptions on the client.
Source
Thrown at packages/common/graphql/src/fetcher.ts:223
headers['content-type'] = 'application/json';
}
const ret = fetcher(
endpoint,
merge(options.context, {
method: 'POST',
headers,
body: isFormData ? body : JSON.stringify(body),
timeout: options.timeout,
signal: options.signal,
})
).then(async res => {
if (res.headers.get('content-type')?.startsWith('application/json')) {
const result = (await res.json()) as ExecutionResult;
if (res.status >= 400 || result.errors) {
if (result.errors && result.errors.length > 0) {
// throw the first error is enough
const firstError = result.errors[0];
throw new GraphQLError(firstError.message, firstError);
} else {
throw new GraphQLError('Empty GraphQL error body');
}
} else if (result.data) {
// we have to cast here because the type of result.data is a union type
return result.data as any;
}
}
throw new GraphQLError(
'GraphQL query responds unexpected result, query ' + options.query.op
);
});
return ret;
};
return gqlFetch;View on GitHub (pinned to b4c8548c09)
Solutions
- Read the underlying GraphQL error message included in the error to find the real cause.
- Fix the failing field or permission issue reported by the first GraphQL error.
- Retry the request after correcting the query or its variables.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/common/graphql/src/fetcher.ts:223 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of toeverything/AFFiNE@b4c8548c09 (2026-08-18).
Data as JSON: /api/errors/0e381486f74b10bf.
Report an issue: GitHub.