Start server with npm start. You can find GraphQL playground at http://localhost:3000
Example asking for all todos
query {
allTodos {
id,
title,
completed
}
}
Response
{
"data": {
"allTodos": [
{
"id": "1",
"title": "do something",
"completed": false
},
{
"id": "2",
"title": "another",
"completed": false
}
]
}
}Example creating new todo object
mutation {
createTodo(id: 2, title: "another", completed: false) {
id
}
}
Response
{
"data": {
"createTodo": {
"id": "2"
}
}
}Example asking for a single todo (notice id argument)
query {
Todo(id: 2) {
id,
title,
completed
}
}
Response
{
"data": {
"Todo": {
"id": "2",
"title": "another",
"completed": false
}
}
}Backend is json-graphql-server. Front-end React code is in src folder, modeled after Getting Started With React And GraphQL post.