Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darahayes/1d1d5b76404b64e1061dadcef88d66cd to your computer and use it in GitHub Desktop.
Save darahayes/1d1d5b76404b64e1061dadcef88d66cd to your computer and use it in GitHub Desktop.
From my medium post on Keycloak auth in GraphQL
const keycloakSubscriptionHandler = new KeycloakSubscriptionHandler({ keycloak })
new SubscriptionServer({
execute,
subscribe,
schema: server.schema,
onConnect: async (connectionParams, websocket, connectionContext) => {
const token = await keycloakSubscriptionHandler.onSubscriptionConnect(connectionParams)
return {
kauth: new KeycloakSubscriptionContext(token)
}
}
}, {
server: httpServer,
path: '/graphql'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment