2016-11-03 21:39:09 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
|
|
|
|
|
|
|
const resolvers = {
|
|
|
|
User: {
|
|
|
|
telescope(user, args, context) {
|
|
|
|
return user.telescope;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
UserTelescope: {
|
|
|
|
downvotedComments(telescope, args, context) {
|
|
|
|
return telescope.downvotedComments ? telescope.downvotedComments : []
|
|
|
|
},
|
|
|
|
downvotedPosts(telescope, args, context) {
|
|
|
|
return telescope.downvotedPosts ? telescope.downvotedPosts : []
|
|
|
|
},
|
|
|
|
upvotedComments(telescope, args, context) {
|
|
|
|
return telescope.upvotedComments ? telescope.upvotedComments : []
|
|
|
|
},
|
|
|
|
upvotedPosts(telescope, args, context) {
|
|
|
|
return telescope.upvotedPosts ? telescope.upvotedPosts : [];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Query: {
|
|
|
|
users(root, args, context) {
|
|
|
|
const options = {
|
|
|
|
limit: 5,
|
2016-11-04 09:31:32 +09:00
|
|
|
fields: context.getViewableFields(context.currentUser, Users)
|
2016-11-03 21:39:09 +09:00
|
|
|
}
|
|
|
|
return context.Users.find({}, {limit: 5}).fetch();
|
|
|
|
},
|
|
|
|
user(root, args, context) {
|
2016-11-04 09:31:32 +09:00
|
|
|
return context.Users.findOne({$or: [{_id: args._id}, {'telescope.slug': args.slug}]}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
2016-11-03 21:39:09 +09:00
|
|
|
},
|
|
|
|
currentUser(root, args, context) {
|
|
|
|
return context && context.userId ? context.Users.findOne(context.userId) : null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-11-04 09:31:32 +09:00
|
|
|
Telescope.graphQL.addResolvers(resolvers);
|