https://github.com/jkettmann/authorization-with-graphql-and-custom-directives
Code example accompanying a tutorial about access-control with GraphQL and directives
https://github.com/jkettmann/authorization-with-graphql-and-custom-directives
Last synced: about 1 month ago
JSON representation
Code example accompanying a tutorial about access-control with GraphQL and directives
- Host: GitHub
- URL: https://github.com/jkettmann/authorization-with-graphql-and-custom-directives
- Owner: jkettmann
- Created: 2019-09-25T05:56:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T11:19:20.000Z (over 2 years ago)
- Last Synced: 2025-02-03T13:15:31.190Z (3 months ago)
- Language: JavaScript
- Homepage: https://jkettmann.com/authorization-with-graphql-and-custom-directives
- Size: 535 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is an example repository accompanying a tutorial about access-control with GraphQL and directives. For more details please have a look at [this blog post](https://jkettmann.com/authorization-with-graphql-and-custom-directives).
## How to install and run the project
To install and start the app run following commands.
```
npm install
npm start
```Visit [http://localhost:4000](http://localhost:4000). You will see the Apollo playground. To have access to the authenticated fields `currentUser`, `currentUser.role` and `currentUser.message` you need to set one of the tokens inside `api/User.js` to the headers. This can be done in the playground bottom left.
```json
{
"authorization": "token-for-maurice-moss"
}
```You can now run following query.
```graphql
{
currentUser {
id
firstName
lastName
role
message(id: "1") {
senderId
receiverId
text
}
}
}
```