Skip to content

Instantly share code, notes, and snippets.

@marekpiechut
Last active January 21, 2019 12:56
Show Gist options
  • Select an option

  • Save marekpiechut/e7086f37acd0dfdc61e749f4e5240acc to your computer and use it in GitHub Desktop.

Select an option

Save marekpiechut/e7086f37acd0dfdc61e749f4e5240acc to your computer and use it in GitHub Desktop.
Authentication and Authorization in NodeJS GraphQL API
const requiresLogin = resolver => (parent, args, context, info) => {
if (context.user && context.user.role === 'MEMBER') {
return resolver(parent, args, context, info)
} else {
throw new AuthenticationError('Unauthorized')
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment