Simple Demo Application
API Built with Apollo Federation Microservices + NodeJs + Express + GraphQL + MongoDB + Passport.
- User Register - Login - Reset Password with Email - Change Password
- List User with Pagination - Delete - Update - Create User with Specific Role
- List of Roles - Delete - Update - Create
- Clone repo
git clone https://github.com/nikulpatel49/apollo-federation-graphql-nodejs-microservice-auth.git
- Install NPM modules
npm install
- Modify
/.env
for Api port (optional) - Run API
npm run server
, browse GraphiQL at http://localhost:4000/graphql
Query - Get User List query { users { _id, name, email } } Set http Header { "Authorization": "Bearer eyJhbGciO9..................." } |
Response { "data": { "users": [ { "_id": "6268e2d3b0ab904a787c8b7d", "name": "user0", "email": "[email protected]" }, { "_id": "626e36045caeed669061b1ec", "name": "Nikul Patel", "email": "[email protected]" }, ] } } |
Query - Get User by Param query { user(_id: "626e36045caeed669061b1ec"){ _id, name, email } } Set http Header { "Authorization": "Bearer eyJhbGciO9..................." } |
Response { "data": { "user": { "_id": "626e36045caeed669061b1ec", "name": "Nikul Patel", "email": "[email protected]" } } } |
Mutation - Register mutation { register( register: { name: "Nikul Patel", email: "[email protected]", password: "user" } ) { status message } } |
Response { "data": { "register": { "status": true, "message": "User has been successfully created", } } } |
Mutation - Login mutation { login(email: "[email protected]", password: "user") { status message token } } |
Response { "data": { "login": { "status": true, "message": "successfully logged user", "token": "Bearer eyJhbGciO9..................." } } } |
Mutation - Delete User mutation { deleteUser(_id: "626e36045caeed669061b1ec"){ status, message, } } Set http Header { "Authorization": "Bearer eyJhbGciO9..................." } |
Response { "data": { "deleteUser": { "status": true, "message": "User has been successfully deleted" } } } |