Add authentication to your GraphQL API with schema directives.
-
@isAuthenticated -
@hasRole -
@hasScope
npm install --save graphql-auth-directives
Then import the schema directives you'd like to use and attach them during your GraphQL schema construction. For example using neo4j-graphql.js' makeAugmentedSchema:
import { IsAuthenticatedDirective, HasRoleDirective } from "graphql-auth-directives";
const augmentedSchema = makeAugmentedSchema({
typeDefs,
schemaDirectives: {
isAuthenticated: IsAuthenticatedDirective,
hasRole: HasRoleDirective
}
});