# deep-data-loader

> A utility for batching and caching requests.

Latest version **0.0.2** (published 2021-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install deep-data-loader
pnpm add deep-data-loader
yarn add deep-data-loader
bun add deep-data-loader
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2021-01-30 |
| First published | 2021-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Philipp Steiger |
| Maintainers | regiets |
| Keywords | batching, caching, GraphQL |

## Links

- npm: https://www.npmjs.com/package/deep-data-loader
- npm.io page: https://npm.io/package/deep-data-loader

## 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

- 0.0.2 (latest) — 2021-01-30
- 0.0.1 — 2021-01-30

## README

# deep-data-loader

DeepDataLoader is a utility class that allows the batching and caching of requests across two levels.

## Get Started

Install DeepDataLoader using npm.

```sh
npm install --save deep-data-loader
```

Create a `DeepDataLoader` instance, passing in an array of primary keys and optionally an array of secondary keys.

```js
const DeepDataLoader = require('deep-data-loader);

const userLoader = new DeepDataLoader((primaryKeys, secondaryKeys) => batchLoadFn(primaryKeys, secondaryKeys));
```

Each instance of the `DeepDataLoader` class represents a unique cache. This cache can be initialised once per app or once per request.

⚠️  If the cache is initialised per application, it may lead to an unintended memory leak.

The keys accepted by the `batchLoadFn` should be in the form of arrays of any type. Using arrays of structural types (non-primitive types) such as objects or arrays is possible but matching is done by reference (remember `{a: 1} !== {a: 1}`).

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