Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darahayes/e7d3984722557e8c1be6b9ab5890c684 to your computer and use it in GitHub Desktop.
Save darahayes/e7d3984722557e8c1be6b9ab5890c684 to your computer and use it in GitHub Desktop.
From my medium post on Keycloak auth in GraphQL
const { auth, hasRole } = require('keycloak-connect-graphql')
const resolvers = {
Article: {
analytics: hasRole('editor')(articleAnalyticsResolver)
},
Query: {
listArticles: auth(listArticlesResolver)
},
mutation: {
publishArticle: hasRole('editor')(publishArticleResolver)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment