TODO
yarn add graphql-directive-auth
- set
appSecret
parameter with your secret to decode JWT token example:
const schema = makeExecutableSchema({
typeDefs,
resolvers,
schemaDirectives: {
isAuthenticated: isAuthenticated('your_secret_token'),
hasRole: hasRole('your_secret_token'),
},
});
TODO
- '@isAuthenticated' - check if user is authenticated
- '@hasRole(role: "user, admin")' - check if user is authenticated
TODO
if you use
graphql-import
then you need to add this definition on top of the schema:
directive @isAuthenticated on FIELD | FIELD_DEFINITION
directive @hasRole(role: String) on FIELD | FIELD_DEFINITION
I would love to see your contribution. ❤️
For local development (and testing), all you have to do is to run yarn
and then yarn dev
. This will start the Apollo server and you are ready to contribute 🎉
Run yarn test (try --watch
flag) for unit tests (we are using Jest)
The MIT License (MIT) 2018 - Luke Czyszczonik - mailto:lukasz.czyszczonik@gmail.com