Skip to content

Instantly share code, notes, and snippets.

@LawJolla
Created February 26, 2018 23:32
Show Gist options
  • Select an option

  • Save LawJolla/3f4c3bba8f5e114ed2a066ca62c4a8a2 to your computer and use it in GitHub Desktop.

Select an option

Save LawJolla/3f4c3bba8f5e114ed2a066ca62c4a8a2 to your computer and use it in GitHub Desktop.
hasRole directive resolver
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