fixed query issues

This commit is contained in:
Wyatt Johnson
2017-11-20 10:32:46 -07:00
parent 1756c7c050
commit debda80db1
6 changed files with 111 additions and 9 deletions
+2
View File
@@ -22,6 +22,7 @@ const TagLink = require('./tag_link');
const Tag = require('./tag');
const UserError = require('./user_error');
const User = require('./user');
const UserState = require('./user_state');
const ValidationUserError = require('./validation_user_error');
const plugins = require('../../services/plugins');
@@ -49,6 +50,7 @@ let resolvers = {
Tag,
UserError,
User,
UserState,
ValidationUserError,
};
+7 -7
View File
@@ -6,7 +6,8 @@ const {
SEARCH_OTHERS_COMMENTS,
UPDATE_USER_ROLES,
SEARCH_COMMENT_METRICS,
LIST_OWN_TOKENS
LIST_OWN_TOKENS,
VIEW_USER_STATUS
} = require('../../perms/constants');
const User = {
@@ -83,12 +84,11 @@ const User = {
}
},
// suspension({id, suspension}, _, {user}) {
// if (user.id !== id && !user.can(VIEW_SUSPENSION_INFO)) {
// return null;
// }
// return suspension;
// }
state(user, args, ctx) {
if (ctx.user && (ctx.user.id === user.id || ctx.user.can(VIEW_USER_STATUS))) {
return user;
}
}
};
// Decorate the User type resolver with a tags field.
+13
View File
@@ -0,0 +1,13 @@
const {
VIEW_USER_STATUS
} = require('../../perms/constants');
const UserState = {
status: (user, args, ctx) => {
if (ctx.user && (ctx.user.id === user.id || ctx.user.can(VIEW_USER_STATUS))) {
return user.status;
}
}
};
module.exports = UserState;