Skip to content
Code example accompanying a tutorial about access-control with GraphQL and directives
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api
.gitignore
README.md
package-lock.json
package.json

README.md

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.

How to install and run the project

To install and start the app run following commands.

npm install
npm start

Visit 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.

{
  "authorization": "token-for-maurice-moss"
}

You can now run following query.

{
  currentUser {
    id
    firstName
    lastName
    role
    message(id: "1") {
      senderId
      receiverId
      text
    }
  }
}
You can’t perform that action at this time.