diff --git a/graph/context.js b/graph/context.js index d765fb8bd..308c86f41 100644 --- a/graph/context.js +++ b/graph/context.js @@ -55,7 +55,7 @@ class Context { this.log = parent.log || createLogger('context', this.id); // Load the current logged in user to `user`, otherwise this will be null. - this.user = get(parent, 'user', null); + this.user = get(parent, 'user'); // Attach the connectors. this.connectors = connectors; diff --git a/graph/loaders/users.js b/graph/loaders/users.js index a3ec3c54e..7b797130d 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -4,7 +4,6 @@ const util = require('./util'); const { SEARCH_OTHER_USERS } = require('../../perms/constants'); -const UsersService = require('../../services/users'); const { escapeRegExp } = require('../../services/regex'); const UserModel = require('../../models/user'); @@ -56,12 +55,9 @@ const genUserByIDs = async (context, ids) => { return []; } - if (ids.length === 1) { - const user = await UsersService.findById(ids[0]); - return [user]; - } - - return UsersService.findByIdArray(ids).then(util.singleJoinBy(ids, 'id')); + return UserModel.find({ id: { $in: ids } }).then( + util.singleJoinBy(ids, 'id') + ); }; /**