Cross-browser function to fetch and parse streaming multipart GraphQL responses, enabling support for the @defer directive in GraphQL clients like Apollo Server and Relay Modern. Current stable version is 2.3.1, released with moderate cadence. Key differentiators: supports both fetch and XMLHttpRequest, handles streaming multipart responses out-of-the-box, and works with Relay's Observable pattern. Requires polyfill for TextEncoder/TextDecoder in older browsers.
npm install fetch-multipart-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Fetches a multipart GraphQL response with @defer and logs each chunk. Uses credentials: 'include' for cookies.
Install and import 'text-encoding-utf-8' before using fetchMultipart.
Ensure the server supports multipart responses (e.g., Apollo Server with @defer). Otherwise, use a regular fetch.
Update onNext to expect an array: parts => /* handle array */
Test your specific browser scenario; consider using fetch if possible.
npm install text-encoding-utf-8 and import it before fetchMultipart.
Use: import fetchMultipart from 'fetch-multipart-graphql';
Provide onNext, onError, and onComplete as options object properties.
Configure server to allow the Origin, methods, and headers.