Skip to content

Graphql foundation with JWT based authentication support

License

Notifications You must be signed in to change notification settings

amalv/graphql-jwt-foundation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graphql-jwt-foundation

Graphql foundation with JWT based authentication support

Prerequisite

You need to set up and run a mysql server and add the configuration under config/routes/database.js

Usage example

  • Install dependencies and start server:
yarn && yarn start
  • Create user using REST API registerend point:
curl -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]", "username": "foo", "password":"test","password2":"test"}' http://localhost:3000/rest/register
  • Login user using REST API login end point:
curl -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"test"}' http://localhost:3000/rest/login
  • Get user using GraphQL API:
curl -i -H "Content-Type:application/json" -H "Authorization: Bearer <token>" -X POST -d '{"query": "{user{id, username}}"}'  http://localhost:3000/graphql
  • Create a note for a user using GraphQL API:
curl -i -H "Content-Type:application/json" -H "Authorization: Bearer <token>" -X POST -d '{"query": "mutation{createNote(userId:1,note:\"this is a note\"){id,userId,note}}"}' http://localhost:3000/graphql
  • Request user with its notes:
curl -i -H "Content-Type:application/json" -H "Authorization: Bearer <token>" -X POST -d '{"query": "{user{id, username, notes{id, note}}}"}'  http://localhost:3000/graphql

About

Graphql foundation with JWT based authentication support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published