GraphiQL API Documentation
    Preparing search index...

    Type Alias PluginTransportContext

    The transport-related subset of the plugin context. Present only when the host uses the transport prop.

    type PluginTransportContext = {
        onBeforeSend: TransportHookRegistry["onBeforeSend"];
        onError: TransportHookRegistry["onError"];
        onResponse: TransportHookRegistry["onResponse"];
    }
    Index
    onBeforeSend: TransportHookRegistry["onBeforeSend"]

    Register a callback that runs before each request is sent. The callback receives the outgoing TransportRequest and must return the (possibly mutated) request, optionally async.

    Returns a cleanup function; call it to remove the hook.

    const ctx = useGraphiQLPluginContext();
    useEffect(() => ctx.transport?.onBeforeSend(req => ({
    ...req,
    headers: { ...req.headers, 'X-Plugin-Header': '1' },
    })), []);
    onError: TransportHookRegistry["onError"]

    Register a callback that runs when a request fails outright — a thrown onBeforeSend hook, a network error — instead of resolving to a TransportResponse. Returns a cleanup function; call it to remove the hook.

    onResponse: TransportHookRegistry["onResponse"]

    Register a callback that runs after each response is received. Returns a cleanup function; call it to remove the hook.