# @envelop/dataloader

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

## Install

```sh
npm install @envelop/dataloader
pnpm add @envelop/dataloader
yarn add @envelop/dataloader
bun add @envelop/dataloader
```

## 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 | 10.0.0 |
| Published | 2026-10-22 |
| First published | 2021-03-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22.15.0 |
| Dependencies | 1 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 8537 |
| Author | Dotan Simha <dotansimha@gmail.com> |
| Maintainers | dotansimha, enisdenjo, theguild-bot |

## Links

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

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0

## Recent versions

- 10.0.0 (latest) — 2026-10-22
- 10.0.0-rc-20261022165416-7c29decb398764e6ac3915e1c539c478cbf19237 (rc) — 2026-10-22
- 10.0.0-alpha-20261019231601-b21e6cedc1a444383d9ce69fe6180f5b4ff67120 (alpha) — 2026-10-19
- 10.0.0-alpha-20261019165905-4e993e96c2903cbe3084f9b49dfbf05042e3fe57 — 2026-10-19
- 10.0.0-alpha-20261019135505-9270088a653c3b9c07f54ef1cb67e69488e4e188 — 2026-10-19
- 10.0.0-alpha-20261009120802-464ace7b331b5693c49d18e270d79cb071e59247 — 2026-10-09
- 10.0.0-alpha-20261006205119-381bef34d7da2fde417073fec18c06eb58224f87 — 2026-10-06
- 10.0.0-alpha-20260929215310-f756e1d4981e8dd5ac5e128b5c2554893ae24a52 — 2026-09-29
- 9.2.1 — 2026-09-16
- 9.2.0 — 2026-08-19
- 10.0.0-alpha-20260420122826-afff629b648b45dc56cbf71f10a44eb4006be3c3 — 2026-04-20
- 9.1.1-alpha-20260211135637-93c20e8d6487b818cbaeae5d79720080f2cdb30f — 2026-02-11
- 9.1.1-alpha-20260211135549-d5b47440cdcf7b0c44848a5d2d061d5bd2270ca4 — 2026-02-11
- 9.1.1-alpha-20260211135457-17dcb4f75d8b14c54c5b72820d4adc64ee17a76b — 2026-02-11
- 9.1.1 — 2026-02-11
- … 1551 more at https://npm.io/package/@envelop/dataloader/versions

## README

## `@envelop/dataloader`

This plugin helps you to create a new [DataLoader](https://github.com/graphql/dataloader) instance
every time your context is being built. The created instance is injected into the `context` with the
name you wish to use.

## Getting Started

```
yarn add dataloader @envelop/dataloader
```

## Usage Example

```ts
import DataLoader from 'dataloader'
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { useDataLoader } from '@envelop/dataloader'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    // ... other plugins ...
    useDataLoader('users', context => new DataLoader(keys => myBatchGetUsers(keys)))
  ]
})
```

Then, when you need to use it in your resolvers, just take it from the context:

```ts
export const resolvers = {
  Query: {
    user: (root, args, context, info) => {
      return context.users.load(args.id)
    }
  }
}
```

## Notes

There are several ways to create and use DataLoader, please refer to:
https://github.com/graphql/dataloader#caching-per-request for more details.

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