directive @bb_primaryKey on FIELD_DEFINITION directive @bb_resolver on FIELD_DEFINITION directive @bb_owned on OBJECT directive @bb_user on OBJECT """ List of tasks or todo items. """ type List @bb_owned { id: ID! title: String! tasks: [Task] user: User! } input ListInput { id: ID! } """ Task or todo item. """ type Task @bb_owned { id: ID! title: String! description: String, completed: Boolean! user: User! list: List! } """ User type; owner of lists and tasks """ type User @bb_user { username: String! @bb_primaryKey name: String tasks: [Task] lists: [List] } input UserInput { username: String! name: String } 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 { createUser( username: String!, name: String! ): User @bb_resolver( _type: INSERT, _object: User, _fields: { username: "$username", name: "$name" }) createList( title: String! user: UserInput! ): List @bb_resolver( _type: INSERT, _object: List, _fields: { title: "$title", user: { username: "$user.$username" } }) updateList( id: ID!, title: String! ): List @bb_resolver( _type: UPDATE, _object: List, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title" }) deleteList(id: ID!): List @bb_resolver(_type: DELETE, _object: List, _filter: { id: { _eq: "$id" } }) createTask( title: String!, description: String, completed: Boolean!, list: ListInput! user: UserInput! ): Task @bb_resolver( _type: INSERT, _object: Task, _fields: { title: "$title", description: "$description", completed: "$completed", list: { id: "$list.$id" }, user: { username: "$user.$username" } }) updateTask( id: ID!, title: String, description: String, completed: Boolean, list: ListInput ): Task @bb_resolver( _type: UPDATE, _object: Task, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title", description: "$description", completed: "$completed", list: { id: "$list.$id" } }) deleteTask(id: ID!): Task @bb_resolver( _type: DELETE, _object: Task, _filter: { id: { _eq: "$id" }}) }