Skip to content

Latest commit

 

History

History
272 lines (262 loc) · 4.83 KB

api.md

File metadata and controls

272 lines (262 loc) · 4.83 KB

Admin Signup

request

  signup(
    username: "username",
    email: "[email protected]",
    password: "password",
    firstName: "John",
    lastName: "Doe",
    adminKey: "ADMIN_KEY"
    ) {
    id
    username
    email
    firstName
    lastName
  }

response

{
  "data": {
    "signup": {
      "id": 1,
      "username": "username",
      "email": "[email protected]",
      "firstName": "John",
      "lastName": "Doe",
    }
  }
}

Query Current User

request

{
  currentUser {
    id
    username
    email
  }
}

response

{
    "data": {
        "currentUser": {
            "id": 4,
            "username": "lin",
            "email": "[email protected]"
        }
    }
}

Admin Login

request

mutation {
  login(email: "[email protected]", password: "password") {
    id
    email
    firstName
    lastName
  }
}

response

{
    "data": {
        "login": {
            "id": 1,
            "email": "[email protected]",
            "firstName": "Daniel",
            "lastName": "Fisher"
        }
    }
}

Add a new Post

request

mutation {
  addPost(
      title: "Api Architecture",
      headerImage: "www.headerImage.com/image.jpg",
      excerpt: "<p>Designing Api Architecture</p>\n",
      author: "Ben Simmone",
      content: "<h1>Api Architecture content</h1>\n",
      createdAt: "2020-04-07",
      updatedAt: "2020-04-07"
      ) {
    id
    title
    headerImage
    excerpt
    slug
    author
    content
    createdAt
    updatedAt
  }
}

response

{
    "data": {
        "addPost": {
            "id": 2,
            "title": "Api Architecture",
            "headerImage": "www.headerImage.com/image.jpg",
            "excerpt": "<p>Designing Api Architecture</p>\n",
            "slug": "api-architecture",
            "author": "Ben Simmone",
            "content": "<h1>Api Architecture content</h1>\n",
            "createdAt": "2020-04-07",
            "updatedAt": "2020-04-07"
        }
    }
}

Delete a post

request

mutation {
    deletePost(id: 1)
}

response

{
    "data": {
        "deletePost": "post with id 1 deleted successfully"
    }
}

Edit a post

request

mutation {
  editPost(
      id: 2,
      title: "Api Architecture",
      headerImage: "www.headerImage.com/image.jpg",
      excerpt: "<p>Designing Api Architecture</p>\n",
      author: "Bola Winslow"
      ) {
    id
    title
    headerImage
    excerpt
    slug
    author
    content
    createdAt
    updatedAt
  }
}

response

{
    "data": {
        "addPost": {
            "id": 2,
            "title": "Api Architecture",
            "headerImage": "www.headerImage.com/image.jpg",
            "excerpt": "<p>Designing Api Architecture</p>\n",
            "slug": "api-architecture",
            "author": "Bola Winslow",
            "content": "<h1>Api Architecture content</h1>\n",
            "createdAt": "2020-04-07",
            "updatedAt": "2020-04-07"
        }
    }
}

Query All POST

request

 {
  getAllNewsletters{
	id
    title
    headerImage
    excerpt
    slug
    author
    content
    createdAt
    updatedAt
  }
}

response

{
    "data": {
        "getAllNewsletters": [
            {
                "id": 6,
                "title": "NewsLetter Documentary",
                "headerImage": "www.headerImage.com/image.jpg",
                "excerpt": "<p>Designing Api Architecture</p>\n",
                "slug": "newsletter-documentary",
                "author": "Tochi",
                "content": "<h1>NewsLetter Documentary</h1>\n",
                "createdAt": "2020-04-07",
                "updatedAt": "2020-04-07"
            },
            {
                "id": 8,
                "title": "Testing Documentary",
                "headerImage": "www.headerImage.com/image.jpg",
                "excerpt": "<p>Designing Api Architecture</p>\n",
                "slug": "testing-documentary",
                "author": "Tochi",
                "content": "<h1>NewsLetter Documentary</h1>\n",
                "createdAt": "2020-04-08",
                "updatedAt": "2020-04-08"
            }
        ]
    }
}

Query A SINGLE POST

request

 {
  getOneNewsletter(id: 8){
	id
    title
    headerImage
    excerpt
    slug
    author
    content
    createdAt
    updatedAt
  }
}

response

{
    "data": {
        "getOneNewsletter": {
            "id": 8,
            "title": "Testing Documentary",
            "headerImage": "www.headerImage.com/image.jpg",
            "excerpt": "<p>Designing Api Architecture</p>\n",
            "slug": "testing-documentary",
            "author": "Tochi",
            "content": "<h1>NewsLetter Documentary</h1>\n",
            "createdAt": "2020-04-08",
            "updatedAt": "2020-04-08"
        }
    }
}