|
1 | 1 | # graphql-compose-dataloader
|
| 2 | +[]() |
| 3 | +[](https://www.npmjs.com/package/graphql-compose-dataloader) [](https://github.com/stoffern/graphql-compose-dataloader/blob/master/LICENSE) |
2 | 4 | Add DataLoader to graphql-composer resolvers.
|
3 | 5 |
|
4 |
| -This is a Work in progress... not working yet |
| 6 | +### Installation |
| 7 | +``` |
| 8 | +npm install graphql-compose-dataloader --save |
| 9 | +``` |
| 10 | +Modules `graphql`, `graphql-compose` are in `peerDependencies`, so should be installed explicitly in your app. They have global objects and should not have ability to be installed as submodule. |
| 11 | + |
| 12 | +### Example |
| 13 | +```js |
| 14 | +import mongoose from 'mongoose'; |
| 15 | +import composeWithMongoose from 'graphql-compose-mongoose'; |
| 16 | +import composeWithDataLoader from 'graphql-compose-dataloader'; |
| 17 | + |
| 18 | +const LanguagesSchema = new mongoose.Schema({ |
| 19 | + language: String, |
| 20 | + skill: { |
| 21 | + type: String, |
| 22 | + enum: [ 'basic', 'fluent', 'native' ], |
| 23 | + }, |
| 24 | +}); |
| 25 | + |
| 26 | +const Languages = mongoose.model('UserModel', UserSchema) |
| 27 | +const LanguagesTC = composeWithDataLoader(composeWithMongoose(Languages),{cacheExpiration: 700}) |
| 28 | +``` |
| 29 | + |
| 30 | +#### Props |
| 31 | +| Prop | Type | Description | |
| 32 | +|---|---|---| |
| 33 | +|**`cacheExpiration`**|`number`|Expiration in number of milliseconds. This will clear the one request sendt via the resolver (_Default: 500_)| |
| 34 | +|**`removeProjection`**|`boolean`|Remove projection, this will request fields on the requested document and put it to cache (_Default: true_)| |
| 35 | +|**`debug`**|`boolean`|Enable debug? (_Default: false_)| |
| 36 | + |
| 37 | +### License |
| 38 | +======= |
| 39 | +[MIT](https://github.com/nodkz/graphql-compose-mongoose/blob/master/LICENSE.md) |
0 commit comments