https://github.com/jkettmann/authorization-with-graphql
https://github.com/jkettmann/authorization-with-graphql
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jkettmann/authorization-with-graphql
- Owner: jkettmann
- Created: 2019-10-09T09:26:42.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T12:15:13.000Z (over 2 years ago)
- Last Synced: 2025-03-30T03:02:32.400Z (about 1 month ago)
- Language: JavaScript
- Size: 482 KB
- Stars: 3
- Watchers: 1
- 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).
## 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: "2") {
senderId
receiverId
text
}
}
}
```