mirror of
https://github.com/wassname/talk.git
synced 2026-07-25 13:30:59 +08:00
- Updated enum values to be uppercase - Updated services to expose service models - Updated models to only export the mongoose model - Moved all mongoose static methods over to new services - Updated tests to refelct new setup BREAKING - Status that were uppercased (caps) have caused issues with the admin pages
17 lines
456 B
JavaScript
17 lines
456 B
JavaScript
const DataLoader = require('dataloader');
|
|
|
|
const UserService = require('../../models/user');
|
|
|
|
const genUserByIDs = (context, ids) => UserService.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))
|
|
}
|
|
});
|