v2.4.0
Minor Changes
-
a3a7b68: Add
onGraphQLErrorsandonRequestErrorhooks so consumers can observe and act on failures the fetcher previously swallowed — both on the client and server fetchers. The library takes no action of its own; each hook decides whether to log, ignore, orthrowto escalate, and both are awaited so a throwing callback rejects the fetch call. They are orthogonal toretry(which controls whether to try again) and fire terminally, after retries are exhausted.onGraphQLErrors— fires when a2xxresponse carries GraphQL errors (e.g. a partial-data response where one field errored), which were previously returned inerrorsand easily ignored.
(errors: GraphQLError[], context: { operationName, documentId?, variables, response, httpResponse }) => void | Promise<void>. The context includes the parsedresponse(so the callback can inspect partialdataalongside the errors) and the rawhttpResponse(status/headers, e.g. a gateway request id). The internalPersistedQueryNotFoundsignal is filtered out oferrors.onRequestError— fires when a request fails with a thrown error: a non-2xx response (aGraphQLFetcherErrorcarrying.status/.body/.response), or a network/timeout error (which previously logged nothing at all).
(error: unknown, context: { operationName, documentId?, variables }) => void | Promise<void>. Not triggered whenonGraphQLErrorsitself throws (that is a GraphQL-error escalation, not a request failure).- Exports
OnGraphQLErrors,OnRequestError,GraphQLErrorContext, andRequestContexttypes. - The
GraphQLErrortype now includes optionalpathandlocations. - The
loggeris now transport-only: it no longer logs GraphQL errors on a 2xx (that isonGraphQLErrors' job). It still logs failed requests, persisted-query fallbacks, and retries.