Answer every operation of a request whose bearer token failed authentication
with that UNAUTHENTICATED error, before any resolver runs.
This is a hook rather than a throw from setContext because a context-factory
error is only reported cleanly by Yoga's own /graphql handler: the
graphql-sse endpoint (/graphql/stream) turns it into an HTTP 500 with a
plain-text stack trace. Stopping execution here gives both transports an
ordinary GraphQL result (HTTP 200, errors[0].extensions.code). The result
carries data: null because graphql-sse only recognises an object with a
data key as a result; without it /graphql/stream answers HTTP 400.
Answer every operation of a request whose bearer token failed authentication with that
UNAUTHENTICATEDerror, before any resolver runs.This is a hook rather than a throw from
setContextbecause a context-factory error is only reported cleanly by Yoga's own/graphqlhandler: the graphql-sse endpoint (/graphql/stream) turns it into an HTTP 500 with a plain-text stack trace. Stopping execution here gives both transports an ordinary GraphQL result (HTTP 200,errors[0].extensions.code). The result carriesdata: nullbecause graphql-sse only recognises an object with adatakey as a result; without it/graphql/streamanswers HTTP 400.