diff --git a/readme.md b/readme.md index 6036b75..81ec05a 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,11 @@ A [terminating Apollo Link](https://apollographql.com/docs/react/api/link/introduction/#the-terminating-link) for [Apollo Client](https://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.mozilla.org/en-US/docs/Web/API/Blob) instances), or else fetches a regular [GraphQL POST or GET request](https://apollographql.com/docs/apollo-server/requests) (depending on the config and GraphQL operation). +- [Installation](#installation) +- [Examples](#examples) +- [Requirements](#requirements) +- [Exports](#exports) + ## Installation To install with [npm](https://npmjs.com/get-npm), run: @@ -12,6 +17,8 @@ To install with [npm](https://npmjs.com/get-npm), run: npm install apollo-upload-client ``` +Polyfill any required globals (see [_**Requirements**_](#requirements)) that are missing in your server and client environments. + Remove any `uri`, `credentials`, or `headers` options from the [`ApolloClient` constructor](https://apollographql.com/docs/react/api/core/ApolloClient/#the-apolloclient-constructor). [Apollo Client](https://apollographql.com/docs/react) can only have 1 [terminating Apollo Link](https://apollographql.com/docs/react/api/link/introduction/#the-terminating-link) that sends the GraphQL requests; if one such as [`HttpLink`](https://apollographql.com/docs/react/api/link/apollo-link-http) is already setup, remove it. @@ -20,7 +27,7 @@ Initialize the client with a [terminating Apollo Link](https://apollographql.com Also ensure the GraphQL server implements the [GraphQL multipart request spec](https://github.com/jaydenseric/graphql-multipart-request-spec) and that uploads are handled correctly in resolvers. -## Usage +## Examples Use [`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.mozilla.org/en-US/docs/Web/API/Blob) instances anywhere within query or mutation variables to send a [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec). @@ -112,12 +119,12 @@ function UploadFile() { ## Requirements -- [Node.js](https://nodejs.org): `^18.15.0 || >=20.4.0` -- [Browsers](https://npm.im/browserslist): `> 0.5%, not OperaMini all, not IE > 0, not dead` +- [Node.js](https://nodejs.org) versions `^18.15.0 || >=20.4.0`. +- Browsers matching the [Browserslist](https://browsersl.ist) query [`> 0.5%, not OperaMini all, not dead`](https://browsersl.ist/?q=%3E+0.5%25%2C+not+OperaMini+all%2C+not+dead). Consider polyfilling: -- [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) +- [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) - [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) - [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)