A comprehensive solution for adding Keycloak authentication and authorization to Express-based GraphQL servers. Version 0.7.0 works with graphql ^0.12.0 to ^15.0.0 and keycloak-connect >=9.0.0. It provides auth at the GraphQL layer via declarative `@auth`, `@hasRole`, and `@hasPermission` directives (Apollo Server) or resolver middleware, with support for subscriptions and token/user info in context. Maintained by AeroGear, it differs from alternatives by focusing solely on Keycloak integration with Express/GraphQL.
npm install keycloak-connect-graphqlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up an Apollo Server Express app with Keycloak auth, using the @auth directive on the 'hello' query.
Upgrade to Apollo Server 4 and use the new directive API, or stick with Apollo Server 2.x.
Ensure `app.use('/graphql', keycloak.middleware())` is called before creating the ApolloServer.Manually configure subscriptions with Keycloak authentication on the WebSocket upgrade.
Use Node.js 12 or later.
Run `npm install keycloak-connect-graphql` and ensure the import matches the package name.
Run `npm install keycloak-connect` and ensure `keycloak = new Keycloak()` is used.
Add `KeycloakTypeDefs` to the typeDefs array and set `schemaDirectives: KeycloakSchemaDirectives` in ApolloServer config.
Ensure `kauth: new KeycloakContext({ req }, keycloak)` is in the context object passed to ApolloServer.