Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darahayes/7b9b97d05b0009af2bef03ce7c4205c7 to your computer and use it in GitHub Desktop.
Save darahayes/7b9b97d05b0009af2bef03ce7c4205c7 to your computer and use it in GitHub Desktop.
From my medium post on Keycloak auth in GraphQL
const resolvers = {
Subscription: {
commentAdded: {
subscribe: () => pubsub.asyncIterator(COMMENT_ADDED)
},
messageAdded: {
subscribe: auth(() => pubsub.asyncIterator(COMMENT_ADDED))
},
alertAdded: {
subscribe: hasRole('admin')(() => pubsub.asyncIterator(ALERT_ADDED))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment