Created
October 18, 2020 20:44
-
-
Save shrirambalakrishnan/7bb5297c84da0780795fd0a40c70f20e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { rule, shield } = require('graphql-shield') | |
// Rules | |
const isUser = rule({ cache: 'contextual' })( | |
async (parent, args, ctx, info) => { | |
let isUser = ctx.user.roles.includes('USER'); | |
console.log(`isUser = ${isUser}`); | |
return isUser; | |
} | |
) | |
// Permissions | |
const permissions = shield({ | |
CommentType: isUser, | |
}) | |
module.exports = { | |
permissions | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment