Skip to content

askmhs/restify-graphql-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt text

Requirements:

  • Node.js v8++
  • MongoDB v3.4++

Getting started:

  • Clone this repo and change the directory to the cloned project
  • Install dependencies by running npm install
  • Create .env file that contains MONGO_URI variable
  • Make sure your MongoDB server is running
  • Run npm start to start the project
  • Open http://localhost:8000/graphiql in browser

Queries

Here are some example of queries

ListUser

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]"
      }
    ]
  }
}

Detail User

Query:

{
  DetailUser(id: "5d2b0f479ec9f60f3578bc65") {
    _id
    name
    phone
    email
  }
}

Response:

{
  "data": {
    "DetailUser": {
      "_id": "5d2b0f479ec9f60f3578bc65",
      "name": "Muhammad Harits Syaifulloh",
      "phone": "081515873888",
      "email": "[email protected]"
    }
  }
}

Mutations

Here is example of mutation

CreateUser

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]"
    }
  }
}

Releases

No releases published

Packages

No packages published