vue-todo/bbconf/todo5_schema.graphql
2023-02-12 11:36:19 +01:00

68 lines
1.7 KiB
GraphQL

type List {
id: ID!
title: String!
tasks: [Task]
user: User!
}
"""
Task or todo item.
"""
type Task {
id: ID!
title: String!
description: String,
completed: Boolean!
user: User!
list: List!
}
"""
User type; owner of lists and tasks
"""
type User {
username: String! @bb_primaryKey
name: String
tasks: [Task]
lists: [List]
}
type Query {
"""
Get a user, this will be used to get the current user as well as the user's lists and tasks.
"""
getUser(
username: String!
): User @bb_resolver(_type: select, _object: User, _filter: { username: { _eq: "$username" } })
}
type Mutation {
createList(
title: String!
user: User! # username needs to be specified as it's non-nullable
): List @bb_resolver(_type: insert, _object: List, _fields: { title: "$title", user: "$user" })
createTask(
title: String!,
description: String,
completed: Boolean!, # default not implemented yet, this needs to be added as it's non-nullable
list: List! # list needs to be specified as it's non-nullable
user: User! # username needs to be specified as it's non-nullable
): Task @bb_resolver(_type: insert, _object: Task, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list", user: "$user" })
updateTask(
id: ID!,
title: String,
description: String,
completed: Boolean,
list: List
): Task @bb_resolver(_type: update, _object: Task, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list" })
deleteTask(id: ID!): Task @bb_resolver(_type: delete, _object: Task, _filter: { id: { _eq: "$id" } })
}