# @apollo/utils.dropunuseddefinitions

> Drop unused definitions from a GraphQL document

Latest version **3.0.0** (published 2023-04-17) · MIT license · 0 weekly downloads

## Install

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

## 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.0.0 |
| Published | 2023-04-17 |
| First published | 2022-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 41 |
| Author | Apollo |
| Maintainers | dkuc, glasser, trevor.scheer, apollo-bot |
| Keywords | apollo, graphql, typescript, node |

## Links

- npm: https://www.npmjs.com/package/@apollo/utils.dropunuseddefinitions
- 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.dropunuseddefinitions

## 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.0.0 (latest) — 2023-04-17
- 2.0.1 — 2023-04-03
- 2.0.0 — 2022-11-18
- 1.1.0 — 2022-04-26
- 1.0.0 — 2022-02-16

## README

# dropUnusedDefinitions

Given an operation document and an operation name, this function will return a
new document with only the definitions required for the operation name provided.

If the provided operation name doesn't match any operation in the document,
`dropUnusedDefinitions` will return the original document.

## Usage

```ts
import { dropUnusedDefinitions } from "@apollo/utils.dropunuseddefinitions";

const operation = parse(`#graphql
  query Drop { ...DroppedFragment }
  fragment DroppedFragment on Query { abc }
  query Keep { ...KeptFragment }
  fragment KeptFragment on Query { def }
`);
const keepOperation = dropUnusedDefinitions(operation, "Keep");
/**
query Keep {
  ...KeptFragment
}

fragment KeptFragment on Query {
  def
}
*/
```

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