1.0.0 • Published 7 years ago
@awoyotoyin/ts-graphql-yoga-express-starter v1.0.0
GraphQL Node Server MongoDB * TS Starter
Prerequisites
Getting Started
git clone+ repo URLcdto repoyarn- installing node packages
Start server
yarn dev - start development server
yarn start - start production server
To run eslint - find lint errors
yarn lint
GraphQL Playground Queries & Mutations
Mutations
SignUp
mutation {
  signup(
    username: "someone"
    password: "password"
  ) {
    token
  }
}Login
mutation {
  login(
    username: "someone"
    password: "password"
  ) {
    token
  }
}Create Todo
mutation {
  createTodo(
    content: "Do you know the way?"
  ) {
    _id,
    content
  }
}
HTTP HEADERS
{
  "Authorization": "Bearer __TOKEN__"
}Update Todo
mutation {
  updateTodo(
    {
        _id: "5a6437d5cacbed9e62630e13",
        content: "Some todo item updated"
    }
  ) {
    _id,
    content
  }
}
HTTP HEADERS
{
  "Authorization": "Bearer __TOKEN__"
}Delete Todo
mutation {
  deleteTodo(
    _id: "5a6437d5cacbed9e62630e13"
  ) {
    _id
  }
}
HTTP HEADERS
{
  "Authorization": "Bearer __TOKEN__"
}Queries
Get Todo
query {
  Todo(
    _id: "5a6437d5cacbed9e62630e13"
  ) {
    _id,
    content
  }
}
HTTP HEADERS
{
  "Authorization": "Bearer __TOKEN__"
}Get All Todos
query {
  allTodos {
    _id,
    content
  }
}
HTTP HEADERS
{
  "Authorization": "Bearer __TOKEN__"
}Better Error Handler
{
  "data": {
    "login": null
  },
  "errors": [
    {
      "message": "The provided credentials are invalid.",
      "name": "WrongCredentials",
      "time_thrown": "2018-05-14T22:34:26.241Z",
      "data": {}
    }
  ]
}1.0.0
7 years ago