Skip to content

Commit 025aa11

Browse files
authored
fix leader name is being returned as anon. (#91)
1 parent 60697e2 commit 025aa11

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

graphql/resolvers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const resolvers = {
1818
hello: () => "Hello world!",
1919
me: (_parent, _args, { user }) => user.populate("landmarks").populate("beacons.leader"),
2020
beacon: async (_parent, { id }, { user }) => {
21-
const beacon = await Beacon.findById(id).populate("landmarks");
21+
const beacon = await Beacon.findById(id).populate("landmarks").populate("leader");
2222
if (!beacon) return new UserInputError("No beacon exists with that id.");
2323
// return beacon iff user in beacon
2424
if (beacon.leader === user.id || beacon.followers.includes(user))
@@ -27,7 +27,7 @@ const resolvers = {
2727
},
2828
nearbyBeacons: async (_, { location }) => {
2929
// get active beacons
30-
const beacons = await Beacon.find({ expiresAt: { $gte: new Date() } });
30+
const beacons = await Beacon.find({ expiresAt: { $gte: new Date() } }).populate("leader");
3131
let nearby = [];
3232
beacons.forEach(b => {
3333
// unpack to not pass extra db fields to function

0 commit comments

Comments
 (0)