Files
talk/graph/loaders/users.js
T
2017-01-24 12:17:06 -07:00

17 lines
461 B
JavaScript

const DataLoader = require('dataloader');
const UsersService = require('../../services/users');
const genUserByIDs = (context, ids) => UsersService.findByIdArray(ids);
/**
* Creates a set of loaders based on a GraphQL context.
* @param {Object} context the context of the GraphQL request
* @return {Object} object of loaders
*/
module.exports = (context) => ({
Users: {
getByID: new DataLoader((ids) => genUserByIDs(context, ids))
}
});