Project is to learn GraphQl. Single api which gives what we query for what we need. Go through their website GraphQL.
Mutation is used for posting and Query is used for getting data from backend
Fork the repository and install local dependencies by running below command.
$ npm install
Run the mongoDB locally and run the below command.
$ node app.js
After execution open the browser and go to this link //localhost:3000/graphql. Now you can see the editor window used for mutation and query
Paste the bellow code in left panel for posting data to DB. If collection is not created bu running mutation command, it will create DB with name employeeDataBase and creates collection employee under it.
mutation {
employeeAdd(id: 824, name: "Rachel Green", department: "clothing", salary: 87000) {
id
name
department
salary
}
}
You can query with the _id created by mongoDB and get required parameters mentioned in query. Run the below command with the query parameter.
query {
employee(_id: "5edcecfe0fdc4f5e0081c89f") {
id
name
department
salary
}
}
Enjoy GraphQL and Explore More.