# nicedataloader

> A wrapper to help pass parameters to graphQL graphql resolver when using dataloader

Latest version **1.0.7** (published 2020-10-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install nicedataloader
pnpm add nicedataloader
yarn add nicedataloader
bun add nicedataloader
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2020-10-05 |
| First published | 2020-09-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | greencoffee |
| Keywords | graphql, dataloader, parameters, arguments |

## Links

- npm: https://www.npmjs.com/package/nicedataloader
- Repository: https://github.com/sgith666/nicedataloader
- Homepage: https://github.com/sgith666/nicedataloader#readme
- Issues: https://github.com/sgith666/nicedataloader/issues
- npm.io page: https://npm.io/package/nicedataloader

## Dependencies (1)

- [dataloader](https://npm.io/package/dataloader.md) ^2.0.0

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

- 1.0.7 (latest) — 2020-10-05
- 1.0.6 — 2020-09-30
- 1.0.5 — 2020-09-30
- 1.0.4 — 2020-09-30
- 1.0.3 — 2020-09-29
- 1.0.2 — 2020-09-28
- 1.0.1 — 2020-09-28
- 1.0.0 — 2020-09-27

## README

## About ##
nicedataloader is designed as a wrapper for dataloader.  It will help pass parameters to graphQL  resolver when using dataloader.


## example ##

resolvers.js

    const NiceDataLoader = require('nicedataloader').NiceDataLoader;
    const pricesLoader = new NiceDataLoader(productResolver.getPrices);
    
    const resolvers = {
        Query: {
            Products: (obj, args, context, info) 
                    => productResolver.getProducts( args, context, info),
        },
        Products: {
            Prices: (parent, args, context, info) 
                        => pricesLoader.get(parent.id, args, context, info),
        .
        .
        .
        
        
ProductResolver.js

    const getPrices = async (keys, args, context, info) => {
        const mysqlPool = context.mysqlPool;
        const customerType = args.customerType;
        return new Promise((resolve, reject) => {
            productModel.getPrices(mysqlPool, keys, customerType).then((result) => {
            resolve(result);
        }).catch((error) => {
            reject(error);
        });
    };

## API ##

| function       | description  | example  | 
| :------------- | :----------: | :----------: | 
|  constructor(_function, cache = false)  | Pass resolver function and set Dataloader cache  | | 
| get(key, args, context, info)  | Pass key, args, context, info to resolver returns results from resolver | | 
| clear() | performs clearAll(), on the dataloader, and sets parameters to null | |

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