Home

Awesome

graphql-compose-dataloader – DEPRECATED

Greenkeeper badge Travis npm version npm Add DataLoader to graphql-composer resolvers.

Deprecation reason

DataLoader cannot be expressed like a simple plugin. Mostly this plugin was used with graphql-compose-mongoose models. From graphql-compose-mongoose@9.0.0 (read more) it starts provide new built-in resolvers dataLoader & dataLoaderMany resolvers which implement DataLoader logic in different manner.

Installation

npm install graphql-compose-dataloader --save

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.

Example

import mongoose from 'mongoose';
import composeWithMongoose from 'graphql-compose-mongoose';
import composeWithDataLoader from 'graphql-compose-dataloader';

const LanguagesSchema = new mongoose.Schema({
  language: String,
  skill: {
    type: String,
    enum: [ 'basic', 'fluent', 'native' ],
  },
});

const Languages = mongoose.model('Languages', LanguagesSchema)
const LanguagesTC = composeWithDataLoader(composeWithMongoose(Languages),{cacheExpiration: 700})

Props

PropTypeDescription
cacheExpirationnumberExpiration in number of milliseconds. This will clear the one request sendt via the resolver (Default: 500)
removeProjectionbooleanRemove projection, this will request fields on the requested document and put it to cache (Default: true)
debugbooleanEnable debug? (Default: false)

License

======= MIT