Skip to content

Latest commit

 

History

History
48 lines (29 loc) · 1.36 KB

README.md

File metadata and controls

48 lines (29 loc) · 1.36 KB

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