Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
88 lines (60 sloc) 1.08 KB

rest-endpoint-example

An Express REST endpoint that will be used to demo converting to GraphQL.

GET /posts

Get all posts

POST /posts

Add a new post. Example structure:

{
  "body": "Hello world",
  "title": "This is a post title",
  "author": "uuid",
  "published": "2017-09-30T08:45:03.632Z"
}

Response

{
  "body": "Hello world",
  "title": "This is a post title",
  "author": "uuid",
  "id": "newuuidforpost",
  "published": "2017-09-30T08:45:03.632Z"
}

GET /posts/:id

Get individual post by id

PUT /posts/:id

Update post with partial

{
  "body": "Updating post body"
}

GET /posts/:id/comments

Get all comments for post

GET /posts/:id/comments/:commentId

Get individual post

GET /users

Get all users

POST /users

Create a new user

Request:

{
 "first": "Helmer",
 "last": "Deckow",
 "email": "Cordell4@gmail.com"
}

Response:

{
 "id": "c46c5b1d-1add-4ebd-98b0-b3cada6b3b81",
 "first": "Helmer",
 "last": "Deckow",
 "email": "Cordell4@gmail.com"
}

GET /users/:id

Get user by id

You can’t perform that action at this time.