Major Changes
- #4392
26ae143Thanks @trevor-scheer! - Remove the deprecatedlegacyClientalias fromCreateFetcherOptions. It duplicatedlegacyWsClient— passlegacyWsClientinstead.
Minor Changes
-
#4333
093cb10Thanks @trevor-scheer! - Add a structuredTransportAPI alongside the existingFetcher.createTransport({...})performs the GraphQL request and returns aTransportResponsecarrying the real HTTP wire metadata (status, headers, timing, size) for queries, mutations, subscriptions, and incremental delivery, so the response pane can surface those values directly instead of fabricating them. That metadata is there even when the response body isn't valid JSON (an HTML error page from a proxy, a plain-text 401), so a broken response still shows its real status code instead of a generic error.<GraphiQL>accepts a newtransportprop, mutually exclusive withfetcherat the type level.Transports support GET, POST, and the HTTP
QUERYmethod per the GraphQL over HTTP spec. Passmethod/supportedMethodsto choose; GET encodes the query into the URL with no body,QUERYsends a JSON body but is safe and idempotent, and mutations are always sent over POST (or blocked when POST is unavailable).Transportexposesurl,method,supportedMethods, and an optionalsetMethod, and the top bar shows the active method and endpoint with an inline switcher that cycles through the supported methods. Every request, incremental delivery on or off, sendsapplication/graphql-response+jsonin itsacceptheader alongsideapplication/json, so spec-compliant servers don't fall back to legacy response semantics. Subscriptions require an explicitsubscriptionClientsatisfying a smallSubscriptionClientcontract: a single.subscribe(request, sink)method thatgraphql-wsandgraphql-sseclients meet directly. The low-levelsimpleHttpTransportandmultipartHttpTransportprimitives also accept an optionalmethod.TransportRequestcarriesextensionsfor GraphQL-over-HTTP extensions such as automatic persisted queries (encoded into the URL forGET, included in the JSON body forPOSTandQUERY), andsignal, anAbortSignalthat cancels an in-flight query or mutation. Stopping a running query or mutation aborts the request; stopping a subscription closes the underlying socket or SSE connection.TransportResponse.okreflects both layers: the HTTP status and the absence of top-level GraphQL errors, so a 401 or 500 is neverok: truejust because its body happens to parse as JSON with noerrors.Plugins can observe and transform traffic through
transport.onBeforeSend,transport.onResponse, andtransport.onError, available viauseGraphiQLPluginContext()(all three return a cleanup function; thetransportfield isundefinedunder the legacyfetcherpath, so guard with optional chaining).onErrorfires when a request fails outright, such as a network error, so plugins can react to failures the same way they observe successful responses.createGraphiQLFetcher, theFetchertype and its companions, and<GraphiQL fetcher={...}>are deprecated but continue to work unchanged. Consumers on the deprecated path see a one-time dismissible banner in the response pane pointing atdocs/migration/graphiql-6.0.0.mdrather than fabricated status/timing/size values. The CDN bundle exposesGraphiQL.createTransportandGraphiQL.createWsClientso script-tag consumers can adopt without a bundler.