mirror of
https://github.com/wassname/talk.git
synced 2026-07-06 05:17:19 +08:00
17 lines
351 B
JavaScript
17 lines
351 B
JavaScript
/**
|
|
* Decorates the typeResolver with the tags field.
|
|
*/
|
|
const decorateWithTags = (typeResolver) => {
|
|
typeResolver.tags = ({tags = []}, _, {user}) => {
|
|
if (user && (user.hasRoles('ADMIN') || user.hasRoles('MODERATOR'))) {
|
|
return tags;
|
|
}
|
|
|
|
return tags.filter((tag) => tag.public);
|
|
};
|
|
};
|
|
|
|
module.exports = {
|
|
decorateWithTags
|
|
};
|