Created
February 26, 2018 23:32
-
-
Save LawJolla/3f4c3bba8f5e114ed2a066ca62c4a8a2 to your computer and use it in GitHub Desktop.
hasRole directive resolver
This file contains hidden or 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 directiveResolvers = { | |
| ..., | |
| hasRole: (next, source, {role}, ctx) => { | |
| const user = getUser() | |
| if (role === user.role) return next(); | |
| throw new Error(`Must have role: ${role}, you have role: ${user.role}`) | |
| }, | |
| ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment