2017-02-02 16:18:33 +01:00
|
|
|
import { GraphQLSchema } from 'meteor/nova:core';
|
2017-01-16 12:24:59 +09:00
|
|
|
|
|
|
|
const specificResolvers = {
|
|
|
|
Post: {
|
2017-02-22 15:54:03 +01:00
|
|
|
async upvoters(post, args, context) {
|
|
|
|
try {
|
|
|
|
if (post.upvoters) {
|
|
|
|
const voters = await context.BatchingUsers.find({_id: {$in: post.upvoters}}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
|
|
|
|
|
|
|
return voters;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
} catch(error) {
|
|
|
|
throw Error(error);
|
|
|
|
}
|
2017-01-16 12:24:59 +09:00
|
|
|
},
|
2017-02-22 15:54:03 +01:00
|
|
|
async downvoters(post, args, context) {
|
|
|
|
try {
|
|
|
|
if (post.downvoters) {
|
|
|
|
const voters = await context.BatchingUsers.find({_id: {$in: post.downvoters}}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
|
|
|
|
|
|
|
return voters;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
} catch(error) {
|
|
|
|
throw Error(error);
|
|
|
|
}
|
2017-01-16 12:24:59 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Comment: {
|
2017-02-22 15:54:03 +01:00
|
|
|
async upvoters(comment, args, context) {
|
|
|
|
try {
|
|
|
|
if (comment.upvoters) {
|
|
|
|
const voters = await context.BatchingUsers.find({_id: {$in: comment.upvoters}}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
|
|
|
|
|
|
|
return voters;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
} catch(error) {
|
|
|
|
throw Error(error);
|
|
|
|
}
|
2017-01-16 12:24:59 +09:00
|
|
|
},
|
2017-02-22 15:54:03 +01:00
|
|
|
async downvoters(comment, args, context) {
|
|
|
|
try {
|
|
|
|
if (comment.downvoters) {
|
|
|
|
const voters = await context.BatchingUsers.find({_id: {$in: comment.downvoters}}, { fields: context.getViewableFields(context.currentUser, context.Users) });
|
|
|
|
|
|
|
|
return voters;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [];
|
|
|
|
} catch(error) {
|
|
|
|
throw Error(error);
|
|
|
|
}
|
2017-01-16 12:24:59 +09:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
GraphQLSchema.addResolvers(specificResolvers);
|