# @apollo/utils.fetcher

> Minimal web-style fetch TypeScript typings

Latest version **3.1.0** (published 2023-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @apollo/utils.fetcher
pnpm add @apollo/utils.fetcher
yarn add @apollo/utils.fetcher
bun add @apollo/utils.fetcher
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-11-08 |
| First published | 2022-04-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 42 |
| Author | Apollo |
| Maintainers | dkuc, glasser, trevor.scheer, apollo-bot |
| Keywords | apollo, graphql, typescript, node |

## Links

- npm: https://www.npmjs.com/package/@apollo/utils.fetcher
- Repository: https://github.com/apollographql/apollo-utils
- Homepage: https://github.com/apollographql/apollo-utils#readme
- Issues: https://github.com/apollographql/apollo-utils/issues
- npm.io page: https://npm.io/package/@apollo/utils.fetcher

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2023-11-08
- 3.0.0 — 2023-04-17
- 2.0.1 — 2023-04-03
- 2.0.0 — 2022-11-18
- 1.1.1 — 2022-10-18
- 1.1.0 — 2022-08-10
- 1.0.0 — 2022-04-28

## README

# Fetcher interface

This package defines TypeScript typings for a subset of the [web `fetch` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API).

The goal is for software that wants to be able to make HTTP requests in a configurable fashion to be able to declare an option of this type; users can pass in any valid `fetch` implementation such as `node-fetch`, `make-fetch-happen`, or `undici`.

The actual `fetch` API is very flexible. You can specify requests either as JSON-style objects or as objects of the `Request` and `Headers` classes. However, some `fetch` implementations distinguish between these cases by using (for example) `instanceof Headers`, where `Headers` is the particular class defined by that implementation. So if you want to write portable code that should work with any `fetch` implementation, you need to use JSON-style objects rather than a particular implementation's classes. (For example, a `Headers` object created with `node-fetch` v2 will not be properly recognized by `make-fetch-happen` v10.)

Additionally, some `fetch` implementations accept various types for their request `body`; for example, `node-fetch` supports the use of `FormData` objects specifically from the `form-data` package. You may choose to use different types for your request `body`, so long as those types are supported by the `fetch` implementation of your choice. You will likely need to use a type assertion to convince TypeScript that your `body` is valid. Unfortunately, because different `fetch` implementations access different `FormData` classes, we weren't excited about the outcome of this [relevant PR](https://github.com/apollographql/apollo-utils/pull/225) and decided to undo it, but might be open to a simpler approach that solves the problem without the need for type assertions.

Specifically, the `Fetcher` interface only declares options that are currently required by the software that uses it, such as Apollo Server and Apollo Gateway. If more options are required (and they are implemented with the same types in all `fetch` implementations), we can add them as needed.

This package is validated to be compatible with the typings of `node-fetch` v2, `make-fetch-happen` v10, and `undici` v5.

---
_Source: https://npm.io/package/@apollo/utils.fetcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
