Skip to content

manaraph/getting-started-with-graphql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

getting-started-with-graphql

GraphQl API with Node ๐Ÿš€

Cloning Repository

git clone https://github.com/manaraph/getting-started-with-graphql.git

Setting up

  • cd getting-started-with-graphql.
  • To play around with graphql run npm install and then npm run trial
  • Navigate into config folder and rename env.global to .env
  • Setup your environment variables:
    • Set your host url default is http://localhost or http://127.0.0.1
    • Set up your port default is 4000
    • Add your MongoDB URI eg. "mongodb://:@xxxxxxxx.mlab.com:57097/dbname"
      • Sign up on mlab.
      • Create a database, you use the free version for aws, google cloud or azure.
      • Create a user and password for your database (this correspond to your and as seen in your MongoDB URI).
      • Please note the URI set in the url './config/.env.global' won't work. (this just a guide on how the URI looks like).

Installation and running app with npm

# install dependencies
npm install 

# Play with grapql app in at localhost:4000
npm run trial

# serve app in developer mode at localhost:4000
npm run dev

# serve app on production mode at localhost:4000
npm start

Running queries and mutations

Create User

mutation {
  addUser(id: "1", name: "Omachonu Manasseh", email: "[email protected]") {
    id
    name
    email
  }
}

Delete User

  mutation {
    deleteUser(id: "1", name: "Omachonu Manasseh", email: "[email protected]") {
      id
      name
      email
    }
  }

Get all Users

  query {
    users {
      id
      name
      email
    }
  }

Get specific User

  query {
    user(id: "1") {
      id
      name
      email
    }
  }

Credits

Adapted from: