GitPedia

Apollo upload client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and GraphQL operation).

From jaydenseric·Updated May 29, 2026·View on GitHub·

A [terminating Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction#the-terminating-link) for [Apollo Client](https://www.apollographql.com/docs/react) that fetches a [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec) if the GraphQL variables contain files (by default [`FileList`](https://developer.mozilla.org/en-US/docs/Web/API/FileList), [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File), or [`Blob`](https://developer.... The project is written primarily in JavaScript, first published in 2017. It has gained significant community traction with 1,541 stars and 154 forks on GitHub. Key topics include: apollo, apollo-client, graphql, maintained, node.

Latest release: v19.0.0Version 19.0.0
August 29, 2025View Changelog →

Apollo upload logo

apollo-upload-client

A terminating Apollo Link for Apollo Client that fetches a GraphQL multipart request if the GraphQL variables contain files (by default FileList, File, or Blob instances), or else fetches a regular GraphQL POST or GET request (depending on the config and GraphQL operation).

Installation

To install with npm, run:

sh
npm install apollo-upload-client

Polyfill any required globals (see Requirements) that are missing in your server and client environments.

Apollo Client can only have 1 terminating Apollo Link that sends the GraphQL requests; if one such as HttpLink is already setup, remove it.

Construct ApolloClient with a terminating Apollo Link using the class UploadHttpLink. For client awareness features, compose the Apollo Link ClientAwarenessLink before the terminating link.

Also ensure the GraphQL server implements the GraphQL multipart request spec and that uploads are handled correctly in resolvers.

Examples

Use FileList, File, or Blob instances anywhere within query or mutation variables to send a GraphQL multipart request.

See also the example API and client.

FileList

tsx
import { gql } from "@apollo/client/core"; import { useMutation } from "@apollo/client/react"; /** React component for a uploading a file list. */ function UploadFileList() { const [mutate] = useMutation< { uploadFiles: { success: boolean; }; }, { files: FileList; } >(mutation); return ( <input type="file" multiple required onChange={({ target: { validity, files } }) => { if (validity.valid && files?.length) mutate({ variables: { files, }, }); }} /> ); } const mutation = gql` mutation ($files: [Upload!]!) { uploadFiles(files: $files) { success } } `;

File

tsx
import { gql } from "@apollo/client/core"; import { useMutation } from "@apollo/client/react"; /** React component for a uploading a file. */ function UploadFile() { const [mutate] = useMutation< { uploadFile: { success: boolean; }; }, { file: File; } >(mutation); return ( <input type="file" required onChange={({ target: { validity, files } }) => { if (validity.valid && files?.[0]) mutate({ variables: { file: files[0], }, }); }} /> ); } const mutation = gql` mutation ($file: Upload!) { uploadFile(file: $file) { success } } `;

Blob

tsx
import { gql } from "@apollo/client/core"; import { useMutation } from "@apollo/client/react"; /** React component for a uploading a blob. */ function UploadBlob() { const [mutate] = useMutation< { uploadFile: { success: boolean; }; }, { file: Blob; } >(mutation); return ( <button type="button" onClick={() => { mutate({ variables: { file: new Blob(["Content here."], { type: "text/plain", }), }, }); }} > Upload </button> ); } const mutation = gql` mutation ($file: Upload!) { uploadFile(file: $file) { success } } `;

To avoid the upload default file name blob, replace the Blob approach with File:

ts
new File( [value], // Custom file name. "text.txt", { type: "text/plain", }, );

Requirements

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

The npm package apollo-upload-client features optimal JavaScript module design. It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the package.json field exports:

Contributors

Showing top 12 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from jaydenseric/apollo-upload-client via the GitHub API.Last fetched: 6/13/2026