From 9a53cfbaa6c2f6a9e191f72fe1f9f4975e1fedb1 Mon Sep 17 00:00:00 2001 From: Markus Thielen Date: Fri, 17 Mar 2023 18:41:43 +0100 Subject: [PATCH] list editing, deleting --- bbconf/bb_todo_resolvers.toml | 141 ++++++++++++++++++++++------------ bbconf/todo_schema.graphql | 7 ++ src/App.vue | 25 +++++- src/components/Lists.vue | 86 +++++++++++++++++++-- src/components/Todo.vue | 47 +++--------- src/util/misc.js | 21 +++++ 6 files changed, 229 insertions(+), 98 deletions(-) create mode 100644 src/util/misc.js diff --git a/bbconf/bb_todo_resolvers.toml b/bbconf/bb_todo_resolvers.toml index 6c3201b..b041b43 100644 --- a/bbconf/bb_todo_resolvers.toml +++ b/bbconf/bb_todo_resolvers.toml @@ -1,34 +1,20 @@ -[resolvers.createTask] -operation_name = "createTask" +[resolvers.getUser] +operation_name = "getUser" -[resolvers.createTask.resolver] -command_type = "SQLInsert" +[resolvers.getUser.resolver] +command_type = "SQLSelect" -[resolvers.createTask.resolver.command] -table = "Task" +[resolvers.getUser.resolver.command] +table = "User" columns = [] -where_clauses = [] +modify_values = [] aggregate_result = true -[[resolvers.createTask.resolver.command.modify_values]] -column = "title" -value = "'$title'" - -[[resolvers.createTask.resolver.command.modify_values]] -column = "description" -value = "'$description'" - -[[resolvers.createTask.resolver.command.modify_values]] -column = "completed" -value = "$completed" - -[[resolvers.createTask.resolver.command.modify_values]] -column = "list_id" -value = "'$list.$id'" - -[[resolvers.createTask.resolver.command.modify_values]] -column = "user_username" -value = "'$user.$username'" +[[resolvers.getUser.resolver.command.where_clauses]] +table = "User" +column = "username" +condition_str = "= '$username'" +index = "" [resolvers.updateTask] operation_name = "updateTask" @@ -63,38 +49,20 @@ column = "id" condition_str = "= '$id'" index = "" -[resolvers.getUser] -operation_name = "getUser" +[resolvers.deleteList] +operation_name = "deleteList" -[resolvers.getUser.resolver] -command_type = "SQLSelect" - -[resolvers.getUser.resolver.command] -table = "User" -columns = [] -modify_values = [] -aggregate_result = true - -[[resolvers.getUser.resolver.command.where_clauses]] -table = "User" -column = "username" -condition_str = "= '$username'" -index = "" - -[resolvers.deleteTask] -operation_name = "deleteTask" - -[resolvers.deleteTask.resolver] +[resolvers.deleteList.resolver] command_type = "SQLDelete" -[resolvers.deleteTask.resolver.command] -table = "Task" +[resolvers.deleteList.resolver.command] +table = "List" columns = [] modify_values = [] aggregate_result = true -[[resolvers.deleteTask.resolver.command.where_clauses]] -table = "Task" +[[resolvers.deleteList.resolver.command.where_clauses]] +table = "List" column = "id" condition_str = "= '$id'" index = "" @@ -119,6 +87,77 @@ value = "'$username'" column = "name" value = "'$name'" +[resolvers.deleteTask] +operation_name = "deleteTask" + +[resolvers.deleteTask.resolver] +command_type = "SQLDelete" + +[resolvers.deleteTask.resolver.command] +table = "Task" +columns = [] +modify_values = [] +aggregate_result = true + +[[resolvers.deleteTask.resolver.command.where_clauses]] +table = "Task" +column = "id" +condition_str = "= '$id'" +index = "" + +[resolvers.createTask] +operation_name = "createTask" + +[resolvers.createTask.resolver] +command_type = "SQLInsert" + +[resolvers.createTask.resolver.command] +table = "Task" +columns = [] +where_clauses = [] +aggregate_result = true + +[[resolvers.createTask.resolver.command.modify_values]] +column = "title" +value = "'$title'" + +[[resolvers.createTask.resolver.command.modify_values]] +column = "description" +value = "'$description'" + +[[resolvers.createTask.resolver.command.modify_values]] +column = "completed" +value = "$completed" + +[[resolvers.createTask.resolver.command.modify_values]] +column = "list_id" +value = "'$list.$id'" + +[[resolvers.createTask.resolver.command.modify_values]] +column = "user_username" +value = "'$user.$username'" + +[resolvers.updateList] +operation_name = "updateList" + +[resolvers.updateList.resolver] +command_type = "SQLUpdate" + +[resolvers.updateList.resolver.command] +table = "List" +columns = [] +aggregate_result = true + +[[resolvers.updateList.resolver.command.modify_values]] +column = "title" +value = "'$title'" + +[[resolvers.updateList.resolver.command.where_clauses]] +table = "List" +column = "id" +condition_str = "= '$id'" +index = "" + [resolvers.createList] operation_name = "createList" diff --git a/bbconf/todo_schema.graphql b/bbconf/todo_schema.graphql index 6fd796e..579c263 100644 --- a/bbconf/todo_schema.graphql +++ b/bbconf/todo_schema.graphql @@ -54,6 +54,13 @@ type Mutation { user: User! # username needs to be specified as it's non-nullable ): List @bb_resolver(_type: insert, _object: List, _fields: { title: "$title", user: "$user" }) + 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, diff --git a/src/App.vue b/src/App.vue index 4aa2291..b3bd6a2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,8 +1,8 @@