diff --git a/bbconf/bb_todo-resolver.toml b/bbconf/bb_todo-resolver.toml index bc655aa..7a6a583 100644 --- a/bbconf/bb_todo-resolver.toml +++ b/bbconf/bb_todo-resolver.toml @@ -1,20 +1,33 @@ -[resolvers.createList] -operation_name = "createList" +[resolvers.createTask] +operation_name = "createTask" -[resolvers.createList.resolver] +[resolvers.createTask.resolver] command_type = "SQLInsert" -[resolvers.createList.resolver.command] -table = "List" +[resolvers.createTask.resolver.command] +table = "Task" columns = [] +nested_modify_tables = [] where_clauses = [] aggregate_result = true -[[resolvers.createList.resolver.command.modify_values]] +[[resolvers.createTask.resolver.command.modify_values]] column = "title" value = "'$title'" -[[resolvers.createList.resolver.command.modify_values]] +[[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'" @@ -27,6 +40,7 @@ command_type = "SQLInsert" [resolvers.createUser.resolver.command] table = "User" columns = [] +nested_modify_tables = [] where_clauses = [] aggregate_result = true @@ -48,6 +62,7 @@ command_type = "SQLDelete" table = "Task" columns = [] modify_values = [] +nested_modify_tables = [] aggregate_result = true [[resolvers.deleteTask.resolver.command.where_clauses]] @@ -56,27 +71,46 @@ column = "id" condition_str = "= '$id'" index = "" -[resolvers.updateList] -operation_name = "updateList" +[resolvers.deleteList] +operation_name = "deleteList" -[resolvers.updateList.resolver] -command_type = "SQLUpdate" +[resolvers.deleteList.resolver] +command_type = "SQLDelete" -[resolvers.updateList.resolver.command] +[resolvers.deleteList.resolver.command] table = "List" columns = [] +modify_values = [] +nested_modify_tables = [] aggregate_result = true -[[resolvers.updateList.resolver.command.modify_values]] -column = "title" -value = "'$title'" - -[[resolvers.updateList.resolver.command.where_clauses]] +[[resolvers.deleteList.resolver.command.where_clauses]] table = "List" column = "id" condition_str = "= '$id'" index = "" +[resolvers.createList] +operation_name = "createList" + +[resolvers.createList.resolver] +command_type = "SQLInsert" + +[resolvers.createList.resolver.command] +table = "List" +columns = [] +nested_modify_tables = [] +where_clauses = [] +aggregate_result = true + +[[resolvers.createList.resolver.command.modify_values]] +column = "title" +value = "'$title'" + +[[resolvers.createList.resolver.command.modify_values]] +column = "user_username" +value = "'$user.$username'" + [resolvers.updateTask] operation_name = "updateTask" @@ -86,6 +120,7 @@ command_type = "SQLUpdate" [resolvers.updateTask.resolver.command] table = "Task" columns = [] +nested_modify_tables = [] aggregate_result = true [[resolvers.updateTask.resolver.command.modify_values]] @@ -110,38 +145,6 @@ 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.getUser] operation_name = "getUser" @@ -152,6 +155,7 @@ command_type = "SQLSelect" table = "User" columns = [] modify_values = [] +nested_modify_tables = [] aggregate_result = true [[resolvers.getUser.resolver.command.where_clauses]] @@ -160,19 +164,23 @@ column = "username" condition_str = "= '$username'" index = "" -[resolvers.deleteList] -operation_name = "deleteList" +[resolvers.updateList] +operation_name = "updateList" -[resolvers.deleteList.resolver] -command_type = "SQLDelete" +[resolvers.updateList.resolver] +command_type = "SQLUpdate" -[resolvers.deleteList.resolver.command] +[resolvers.updateList.resolver.command] table = "List" columns = [] -modify_values = [] +nested_modify_tables = [] aggregate_result = true -[[resolvers.deleteList.resolver.command.where_clauses]] +[[resolvers.updateList.resolver.command.modify_values]] +column = "title" +value = "'$title'" + +[[resolvers.updateList.resolver.command.where_clauses]] table = "List" column = "id" condition_str = "= '$id'" diff --git a/src/components/Todo.vue b/src/components/Todo.vue index 8d51d82..b561052 100644 --- a/src/components/Todo.vue +++ b/src/components/Todo.vue @@ -141,7 +141,9 @@ export default { request ).then(data => { /* Save the task's id in case it was just created */ - task.id = data.Task.id; + if (!task.id) { + task.id = data.createTask.id; + } }).catch(e => { const errMsg = `Failed to save task: ${e}`; console.error(errMsg); diff --git a/src/store.js b/src/store.js index 6b736eb..f2c07c4 100644 --- a/src/store.js +++ b/src/store.js @@ -13,7 +13,7 @@ export const store = reactive({ userName: "stranger", /** base URL of basebox broker host */ - baseboxHost: process.env.BASEBOX_HOST || "http://127.0.0.1:8080", + baseboxHost: import.meta.env.BASEBOX_HOST || "http://127.0.0.1:8080", /** basebox session data */ session: {}, @@ -118,8 +118,8 @@ export async function storeInit(session) { } } }`).then(data => { - store.lists = data.User.lists ? data.User.lists : []; - store.tasks = data.User.tasks ? data.User.tasks : []; + store.lists = data.getUser.lists ? data.getUser.lists : []; + store.tasks = data.getUser.tasks ? data.getUser.tasks : []; /* create default list if necessary */ if (store.lists.length === 0) { gqlQuery(`mutation {