This is a simple API using Node.js, Apollo Server and GraphQL.
- Node.js
- Yarn
- Install the dependencies
yarn
- Run the server
yarn start
- Access the GraphQL Playground
http://localhost:4000/
Its possible to query the users, todos and todo by id.
Change the query to get the data you want.
query GetUsers {
users {
name,
todos {
text
}
}
}
query GetTodos {
todos {
id
text
completed
user {
name,
}
}
}
query GetTodoById {
todoById(id: 1) {
id
text
completed
user {
id
name
}
}
}
query GetCompletedTodo {
todoCompleted(completed: true) {
text
user {
name
}
}
}
Its possible to create, update, delete and set a todo as completed.
Change the mutation to get the data you want.
mutation CreateTodo {
addTodo(text: "Wash car", completed: false, userId: 1) {
text
}
}
mutation SetTodoCompleted {
setTodoCompleted(id: 1, completed: true) {
text
completed
}
}
mutation UpdateTodo {
updateTodo(id: 1, text: "Changed Todo") {
text
}
}
mutation DeleteTodo {
deleteTodo(id: 1) {
id
}
}