Skip to content
Presentation for DSM.JS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.babelrc
.eslintignore
.gitignore
.nvmrc
README.md
db.json
package-lock.json
package.json
yarn.lock

README.md

REST to GraphQL

A simple example showing off how GraphQL can simplify developement for API consumers.

REST examples

To demonstate how a typical REST api works, there's a single endpoint (/user), that can be consumed with the standard GET,POST,PUT,and DELETE requests.

Create a user

  http://localhost:4000/user \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
	"email":"newuser@users4dayz.com",
	"name":"Micheal Scott"
}'

Get all users

  http://localhost:4000/user \
  -H 'Cache-Control: no-cache'

Get a user or users by given paraments

  'http://localhost:4000/user?email=new@email.com' \
  -H 'Cache-Control: no-cache'

Update a user

  http://localhost:4000/user \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
	"_id":"5cc132b3a4bff7693c00e95b",
	"name":"Dwight Schrute"
}'

Delete a user

curl -X DELETE \
  http://localhost:4000/user \
  -H 'Cache-Control: no-cache' \
  -H 'Content-Type: application/json' \
  -d '{
	"_id": "5cc121bc60732197ceed44c9"
}'
You can’t perform that action at this time.