- Node.js v8++
- MongoDB v3.4++
- Clone this repo and change the directory to the cloned project
- Install dependencies by running
npm install
- Create
.env
file that containsMONGO_URI
variable - Make sure your MongoDB server is running
- Run
npm start
to start the project - Open
http://localhost:8000/graphiql
in browser
Here are some example of queries
Query:
{
ListUser {
_id
name
phone
email
}
}
Reponse:
{
"data": {
"ListUser": [
{
"_id": "5d2b0f479ec9f60f3578bc65",
"name": "Muhammad Harits Syaifulloh",
"phone": "081515873888",
"email": "[email protected]"
},
{
"_id": "5d2b0fe49ec9f60f3578bc66",
"name": "John Doe",
"phone": "081234567890",
"email": "[email protected]"
}
]
}
}
Query:
{
DetailUser(id: "5d2b0f479ec9f60f3578bc65") {
_id
name
phone
email
}
}
Response:
{
"data": {
"DetailUser": {
"_id": "5d2b0f479ec9f60f3578bc65",
"name": "Muhammad Harits Syaifulloh",
"phone": "081515873888",
"email": "[email protected]"
}
}
}
Here is example of mutation
Mutation:
mutation {
CreateUser(data: {
name: "Foo Bar"
email: "[email protected]"
phone: "087736473642"
})
}
Response:
{
"data": {
"CreateUser": {
"_id": "5d2b1ba68f6e1d10537cef12",
"name": "Foo Bar",
"phone": "087736473642",
"email": "[email protected]"
}
}
}