# @envelop/resource-limitations

> A rate-limit implementation based on resource limitations and static calculation of the score (similar to GitHub GraphQL API)

Latest version **9.0.0** (published 2026-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install @envelop/resource-limitations
pnpm add @envelop/resource-limitations
yarn add @envelop/resource-limitations
bun add @envelop/resource-limitations
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 9.0.0 |
| Published | 2026-10-22 |
| First published | 2021-07-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.15.0 |
| Dependencies | 3 |
| Unpacked size | 27.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8535 |
| Author | Laurin Quast <laurinquast@googlemail.com> |
| Maintainers | dotansimha, enisdenjo, theguild-bot |

## Links

- npm: https://www.npmjs.com/package/@envelop/resource-limitations
- Repository: https://github.com/graphql-hive/graphql-yoga
- Homepage: https://github.com/graphql-hive/graphql-yoga/tree/main/packages/envelop/plugins/resource-limitations#readme
- npm.io page: https://npm.io/package/@envelop/resource-limitations

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0
- [@graphql-tools/utils](https://npm.io/package/@graphql-tools/utils.md) ^13.0.0
- [@envelop/extended-validation](https://npm.io/package/@envelop/extended-validation.md) ^8.0.0

## Recent versions

- 9.0.0 (latest) — 2026-10-22
- 9.0.0-rc-20261022165416-7c29decb398764e6ac3915e1c539c478cbf19237 (rc) — 2026-10-22
- 9.0.0-alpha-20261019231601-b21e6cedc1a444383d9ce69fe6180f5b4ff67120 (alpha) — 2026-10-19
- 9.0.0-alpha-20261019165905-4e993e96c2903cbe3084f9b49dfbf05042e3fe57 — 2026-10-19
- 9.0.0-alpha-20261019135505-9270088a653c3b9c07f54ef1cb67e69488e4e188 — 2026-10-19
- 9.0.0-alpha-20261009120802-464ace7b331b5693c49d18e270d79cb071e59247 — 2026-10-09
- 8.2.3 — 2026-10-08
- 8.2.3-alpha-20261008131303-049f4f61aa384845ff64598c0af8943815cfae7c — 2026-10-08
- 8.2.2-alpha-20261008130958-e30468c468ea9ccc39e326f862b2f09755d8d3f5 — 2026-10-08
- 8.2.2 — 2026-10-08
- 8.2.2-alpha-20261008120758-3fee8aba89a217d0d86af9e5c5e085c76b095445 — 2026-10-08
- 8.2.2-alpha-20261008120455-82eb244b74bd5e970c2ba4295cb5225b5c576500 — 2026-10-08
- 8.2.2-alpha-20261007143123-87dafff7f26ca8824990a6d5cb0d119ea7ebe85e — 2026-10-07
- 9.0.0-alpha-20261006205119-381bef34d7da2fde417073fec18c06eb58224f87 — 2026-10-06
- 9.0.0-alpha-20260929215310-f756e1d4981e8dd5ac5e128b5c2554893ae24a52 — 2026-09-29
- … 1629 more at https://npm.io/package/@envelop/resource-limitations/versions

## README

## `@envelop/resource-limitations`

This plugins uses `extended-validation` concept
([details here](https://github.com/graphql-hive/envelop/tree/main/packages/plugins/extended-validation#envelopextended-validation))
for implementing a resource-limitations rate-limit similar to GitHub GraphQL API (see
https://docs.github.com/en/graphql/overview/resource-limitations for more details)

## Getting Started

```
yarn add @envelop/resource-limitations
```

## Usage Example

```ts
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useResourceLimitations } from '@envelop/resource-limitations'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useResourceLimitations({
      nodeCostLimit: 500000, // optional, default to 500000
      paginationArgumentMaximum: 100, // optional, default to 100
      paginationArgumentMinimum: 1, // optional, default to 1
      paginationArgumentScalars: ['ConnectionInt'], // optional, use if connections use a different scalar type as the argument instead of `Int`
      extensions: false // set this to `true` in order to add the calculated const to the response of queries
    })
  ]
})
```

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