All graphql requests goes to http://localhost:8080/graphql
with HTTP method POST
Queries are used to retrieve data and mutations are for creating, updating and removing resources.
In the request body you must pass a json object with a property query where you can pass the query or mutation you need
{
"query": "query {allTasks { id, title}}"
}
{
"id": 1,
"title": String,
"description": String,
"status": String,
"created": LocalDateTime,
"updated": LocalDateTime,
"dueDate": LocalDateTime,
"timeEstimation": int,
"category": {
"id": int,
"name": String,
"description": String,
"created": LocalDateTime,
"updated": LocalDateTime
},
"tag": {
"id": 1,
"name": String,
"description": string,
"created": LocalDateTime,
"updated": LocalDateTime
},
}
{
"data": {
"allTasks": [
{
// Task fields
...
},
]
}
}
Error
{
"errors": [
{
"message": "Task not found",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": ["taskById"],
"extensions": {
"classification": "NOT_FOUND"
}
}
],
"data": {
"taskById": null
}
}
query {
allTasks {
// Task fields
...
}
}
// Reponds with task list
query {
taskById(id: 1) {
// Task fields
...
}
}
query MyQuery {
tasksByTagId
}
// Reponds with task list
query {
tasksByCategoryId(categoryId: 1) {
// Task fields
...
}
}
// Reponds with task list
mutation {
addTask(
task: {
description: String,
status: String,
title: String
}) {
// Task fields
...
}
}
mutation {
deleteTask(id: Int)
}
// Always responds with a string
mutation {
updateTask(
task: {
categoryId: Int,
description: String,
id: Int,
status: String,
tagId: Int,
title: String
}) {
// Task fields
...
}
}