Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const posts = require("./posts");
module.exports = {
Query: {
posts: (_parent, _args, context, _info) => {
return posts.filter(post => {
const isAuthor = post.authorId === context.user.id;
const isAdmin = context.user.roles.includes("admin");
return isAuthor || isAdmin;
});
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment