Updated schema and generated files for v1.0

This commit is contained in:
Kevin Naidoo 2023-10-30 17:22:40 +01:00
parent 1cf97de48a
commit 20de6a58e4
4 changed files with 217 additions and 113 deletions

View File

@ -1,3 +1,6 @@
--
-- Generated by basebox compiler (bbc) version 0.1.0-beta.23 at 2023-10-30 16:54:43+01:00
--
CREATE EXTENSION IF NOT EXISTS pgcrypto; CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE "List" ( CREATE TABLE "List" (
@ -32,3 +35,11 @@ ALTER TABLE "Task" ADD CONSTRAINT fk_task_2 FOREIGN KEY ("user_username") REFERE
ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list_id") REFERENCES "List" ("id"); ALTER TABLE "Task" ADD CONSTRAINT fk_task_3 FOREIGN KEY ("list_id") REFERENCES "List" ("id");
ALTER TABLE "User" ADD CONSTRAINT uq_user_4 UNIQUE (".ownerId");
ALTER TABLE "List" ADD COLUMN ".ownerId" VARCHAR NOT NULL;
ALTER TABLE "Task" ADD COLUMN ".ownerId" VARCHAR NOT NULL;
ALTER TABLE "User" ADD COLUMN ".ownerId" VARCHAR NOT NULL;

View File

@ -1,40 +1,22 @@
[resolvers.getUser] #
operation_name = "getUser" # Generated by bbc (basebox compiler) version 0.1.0-beta.23 at 2023-10-30 16:54:43+01:00
#
[resolvers.deleteTask]
operation_name = "deleteTask"
[resolvers.getUser.resolver] [resolvers.deleteTask.resolver.QueryBuilder]
command_type = "SQLDelete"
[resolvers.deleteTask.resolver.QueryBuilder.command]
table = "Task"
command_type = "SQLSelect" command_type = "SQLSelect"
[resolvers.getUser.resolver.command]
table = "User"
columns = [] columns = []
modify_values = [] modify_values = []
nested_modify_tables = [] nested_modify_tables = []
aggregate_result = true aggregate_result = true
[[resolvers.getUser.resolver.command.where_clauses]] [[resolvers.deleteTask.resolver.QueryBuilder.command.where_clauses]]
table = "User" table = "Task"
column = "username"
condition_str = "= '$username'"
index = ""
[resolvers.updateList]
operation_name = "updateList"
[resolvers.updateList.resolver]
command_type = "SQLUpdate"
[resolvers.updateList.resolver.command]
table = "List"
columns = []
nested_modify_tables = []
aggregate_result = true
[[resolvers.updateList.resolver.command.modify_values]]
column = "title"
value = "'$title'"
[[resolvers.updateList.resolver.command.where_clauses]]
table = "List"
column = "id" column = "id"
condition_str = "= '$id'" condition_str = "= '$id'"
index = "" index = ""
@ -42,146 +24,200 @@ index = ""
[resolvers.createList] [resolvers.createList]
operation_name = "createList" operation_name = "createList"
[resolvers.createList.resolver] [resolvers.createList.resolver.QueryBuilder]
command_type = "SQLInsert" command_type = "SQLInsert"
[resolvers.createList.resolver.command] [resolvers.createList.resolver.QueryBuilder.command]
table = "List" table = "List"
command_type = "SQLSelect"
columns = [] columns = []
nested_modify_tables = [] nested_modify_tables = []
where_clauses = [] where_clauses = []
aggregate_result = true aggregate_result = true
[[resolvers.createList.resolver.command.modify_values]] [[resolvers.createList.resolver.QueryBuilder.command.modify_values]]
column = "title" column = "title"
value = "'$title'" value = "'$title'"
[[resolvers.createList.resolver.command.modify_values]] [[resolvers.createList.resolver.QueryBuilder.command.modify_values]]
column = "user_username" column = "user_username"
value = "'$user.$username'" value = "'$user.$username'"
[resolvers.createUser]
operation_name = "createUser"
[resolvers.createUser.resolver]
command_type = "SQLInsert"
[resolvers.createUser.resolver.command]
table = "User"
columns = []
nested_modify_tables = []
where_clauses = []
aggregate_result = true
[[resolvers.createUser.resolver.command.modify_values]]
column = "username"
value = "'$username'"
[[resolvers.createUser.resolver.command.modify_values]]
column = "name"
value = "'$name'"
[resolvers.deleteTask]
operation_name = "deleteTask"
[resolvers.deleteTask.resolver]
command_type = "SQLDelete"
[resolvers.deleteTask.resolver.command]
table = "Task"
columns = []
modify_values = []
nested_modify_tables = []
aggregate_result = true
[[resolvers.deleteTask.resolver.command.where_clauses]]
table = "Task"
column = "id"
condition_str = "= '$id'"
index = ""
[resolvers.createTask] [resolvers.createTask]
operation_name = "createTask" operation_name = "createTask"
[resolvers.createTask.resolver] [resolvers.createTask.resolver.QueryBuilder]
command_type = "SQLInsert" command_type = "SQLInsert"
[resolvers.createTask.resolver.command] [resolvers.createTask.resolver.QueryBuilder.command]
table = "Task" table = "Task"
command_type = "SQLSelect"
columns = [] columns = []
nested_modify_tables = [] nested_modify_tables = []
where_clauses = [] where_clauses = []
aggregate_result = true aggregate_result = true
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.QueryBuilder.command.modify_values]]
column = "title" column = "title"
value = "'$title'" value = "'$title'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.QueryBuilder.command.modify_values]]
column = "description" column = "description"
value = "'$description'" value = "'$description'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.QueryBuilder.command.modify_values]]
column = "completed" column = "completed"
value = "'$completed'" value = "'$completed'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.QueryBuilder.command.modify_values]]
column = "list_id" column = "list_id"
value = "'$list.$id'" value = "'$list.$id'"
[[resolvers.createTask.resolver.command.modify_values]] [[resolvers.createTask.resolver.QueryBuilder.command.modify_values]]
column = "user_username" column = "user_username"
value = "'$user.$username'" value = "'$user.$username'"
[resolvers.deleteList] [resolvers.deleteList]
operation_name = "deleteList" operation_name = "deleteList"
[resolvers.deleteList.resolver] [resolvers.deleteList.resolver.QueryBuilder]
command_type = "SQLDelete" command_type = "SQLDelete"
[resolvers.deleteList.resolver.command] [resolvers.deleteList.resolver.QueryBuilder.command]
table = "List" table = "List"
command_type = "SQLSelect"
columns = [] columns = []
modify_values = [] modify_values = []
nested_modify_tables = [] nested_modify_tables = []
aggregate_result = true aggregate_result = true
[[resolvers.deleteList.resolver.command.where_clauses]] [[resolvers.deleteList.resolver.QueryBuilder.command.where_clauses]]
table = "List" table = "List"
column = "id" column = "id"
condition_str = "= '$id'" condition_str = "= '$id'"
index = "" index = ""
[resolvers._bb_user_User]
operation_name = "_bb_user_User"
[resolvers._bb_user_User.resolver.InternalQueryBuilder]
command_type = "SQLSelect"
[resolvers._bb_user_User.resolver.InternalQueryBuilder.command]
table = "User"
command_type = "SQLSelect"
modify_values = []
nested_modify_tables = []
aggregate_result = true
[[resolvers._bb_user_User.resolver.InternalQueryBuilder.command.columns]]
[resolvers._bb_user_User.resolver.InternalQueryBuilder.command.columns.Column]
table = "User"
column = "username"
[[resolvers._bb_user_User.resolver.InternalQueryBuilder.command.where_clauses]]
table = "User"
column = ".ownerId"
condition_str = "= $1"
index = ""
[resolvers.getUser]
operation_name = "getUser"
[resolvers.getUser.resolver.QueryBuilder]
command_type = "SQLSelect"
[resolvers.getUser.resolver.QueryBuilder.command]
table = "User"
command_type = "SQLSelect"
columns = []
modify_values = []
nested_modify_tables = []
aggregate_result = true
[[resolvers.getUser.resolver.QueryBuilder.command.where_clauses]]
table = "User"
column = "username"
condition_str = "= '$username'"
index = ""
[resolvers.updateTask] [resolvers.updateTask]
operation_name = "updateTask" operation_name = "updateTask"
[resolvers.updateTask.resolver] [resolvers.updateTask.resolver.QueryBuilder]
command_type = "SQLUpdate" command_type = "SQLUpdate"
[resolvers.updateTask.resolver.command] [resolvers.updateTask.resolver.QueryBuilder.command]
table = "Task" table = "Task"
command_type = "SQLSelect"
columns = [] columns = []
nested_modify_tables = [] nested_modify_tables = []
aggregate_result = true aggregate_result = true
[[resolvers.updateTask.resolver.command.modify_values]] [[resolvers.updateTask.resolver.QueryBuilder.command.modify_values]]
column = "title" column = "title"
value = "'$title'" value = "'$title'"
[[resolvers.updateTask.resolver.command.modify_values]] [[resolvers.updateTask.resolver.QueryBuilder.command.modify_values]]
column = "description" column = "description"
value = "'$description'" value = "'$description'"
[[resolvers.updateTask.resolver.command.modify_values]] [[resolvers.updateTask.resolver.QueryBuilder.command.modify_values]]
column = "completed" column = "completed"
value = "'$completed'" value = "'$completed'"
[[resolvers.updateTask.resolver.command.modify_values]] [[resolvers.updateTask.resolver.QueryBuilder.command.modify_values]]
column = "list_id" column = "list_id"
value = "'$list.$id'" value = "'$list.$id'"
[[resolvers.updateTask.resolver.command.where_clauses]] [[resolvers.updateTask.resolver.QueryBuilder.command.where_clauses]]
table = "Task" table = "Task"
column = "id" column = "id"
condition_str = "= '$id'" condition_str = "= '$id'"
index = "" index = ""
[resolvers.createUser]
operation_name = "createUser"
[resolvers.createUser.resolver.QueryBuilder]
command_type = "SQLInsert"
[resolvers.createUser.resolver.QueryBuilder.command]
table = "User"
command_type = "SQLSelect"
columns = []
nested_modify_tables = []
where_clauses = []
aggregate_result = true
[[resolvers.createUser.resolver.QueryBuilder.command.modify_values]]
column = "username"
value = "'$username'"
[[resolvers.createUser.resolver.QueryBuilder.command.modify_values]]
column = "name"
value = "'$name'"
[resolvers.updateList]
operation_name = "updateList"
[resolvers.updateList.resolver.QueryBuilder]
command_type = "SQLUpdate"
[resolvers.updateList.resolver.QueryBuilder.command]
table = "List"
command_type = "SQLSelect"
columns = []
nested_modify_tables = []
aggregate_result = true
[[resolvers.updateList.resolver.QueryBuilder.command.modify_values]]
column = "title"
value = "'$title'"
[[resolvers.updateList.resolver.QueryBuilder.command.where_clauses]]
table = "List"
column = "id"
condition_str = "= '$id'"
index = ""

View File

@ -88,7 +88,7 @@
"gql_field": "user", "gql_field": "user",
"gql_type": "User", "gql_type": "User",
"sql_join_type": { "sql_join_type": {
"OneToMany": { "ManyToOne": {
"sql_table_of_object": "List", "sql_table_of_object": "List",
"sql_table_of_field": "User", "sql_table_of_field": "User",
"sql_mapped_columns": [ "sql_mapped_columns": [
@ -107,7 +107,7 @@
"gql_field": "lists", "gql_field": "lists",
"gql_type": "List", "gql_type": "List",
"sql_join_type": { "sql_join_type": {
"ManyToOne": { "OneToMany": {
"sql_table_of_object": "User", "sql_table_of_object": "User",
"sql_table_of_field": "List", "sql_table_of_field": "List",
"sql_mapped_columns": [ "sql_mapped_columns": [
@ -126,7 +126,7 @@
"gql_field": "user", "gql_field": "user",
"gql_type": "User", "gql_type": "User",
"sql_join_type": { "sql_join_type": {
"OneToMany": { "ManyToOne": {
"sql_table_of_object": "Task", "sql_table_of_object": "Task",
"sql_table_of_field": "User", "sql_table_of_field": "User",
"sql_mapped_columns": [ "sql_mapped_columns": [
@ -145,7 +145,7 @@
"gql_field": "tasks", "gql_field": "tasks",
"gql_type": "Task", "gql_type": "Task",
"sql_join_type": { "sql_join_type": {
"ManyToOne": { "OneToMany": {
"sql_table_of_object": "User", "sql_table_of_object": "User",
"sql_table_of_field": "Task", "sql_table_of_field": "Task",
"sql_mapped_columns": [ "sql_mapped_columns": [
@ -164,7 +164,7 @@
"gql_field": "list", "gql_field": "list",
"gql_type": "List", "gql_type": "List",
"sql_join_type": { "sql_join_type": {
"OneToMany": { "ManyToOne": {
"sql_table_of_object": "Task", "sql_table_of_object": "Task",
"sql_table_of_field": "List", "sql_table_of_field": "List",
"sql_mapped_columns": [ "sql_mapped_columns": [
@ -183,7 +183,7 @@
"gql_field": "tasks", "gql_field": "tasks",
"gql_type": "Task", "gql_type": "Task",
"sql_join_type": { "sql_join_type": {
"ManyToOne": { "OneToMany": {
"sql_table_of_object": "List", "sql_table_of_object": "List",
"sql_table_of_field": "Task", "sql_table_of_field": "Task",
"sql_mapped_columns": [ "sql_mapped_columns": [

View File

@ -1,17 +1,26 @@
directive @bb_primaryKey on FIELD_DEFINITION directive @bb_primaryKey on FIELD_DEFINITION
directive @bb_resolver on FIELD_DEFINITION directive @bb_resolver on FIELD_DEFINITION
directive @bb_owned on OBJECT
directive @bb_user on OBJECT
type List { """
List of tasks or todo items.
"""
type List @bb_owned {
id: ID! id: ID!
title: String! title: String!
tasks: [Task] tasks: [Task]
user: User! user: User!
} }
input ListInput {
id: ID!
}
""" """
Task or todo item. Task or todo item.
""" """
type Task { type Task @bb_owned {
id: ID! id: ID!
title: String! title: String!
description: String, description: String,
@ -23,13 +32,17 @@ type Task {
""" """
User type; owner of lists and tasks User type; owner of lists and tasks
""" """
type User { type User @bb_user {
username: String! @bb_primaryKey username: String! @bb_primaryKey
name: String name: String
tasks: [Task] tasks: [Task]
lists: [List] lists: [List]
} }
input UserInput {
username: String!
name: String
}
type Query { type Query {
@ -38,7 +51,11 @@ type Query {
""" """
getUser( getUser(
username: String! username: String!
): User @bb_resolver(_type: SELECT, _object: User, _filter: { username: { _eq: "$username" } }) ): User
@bb_resolver(
_type: SELECT,
_object: User,
_filter: { username: { _eq: "$username" } })
} }
@ -47,36 +64,76 @@ type Mutation {
createUser( createUser(
username: String!, username: String!,
name: String! name: String!
): User @bb_resolver(_type: INSERT, _object: User, _fields: { username: "$username", name: "$name" }) ): User
@bb_resolver(
_type: INSERT,
_object: User,
_fields: { username: "$username", name: "$name" })
createList( createList(
title: String! title: String!
user: User! # username needs to be specified as it's non-nullable user: UserInput!
): List @bb_resolver(_type: INSERT, _object: List, _fields: { title: "$title", user: "$user" }) ): List
@bb_resolver(
_type: INSERT,
_object: List,
_fields: {
title: "$title",
user: { username: "$user.$username" }
})
updateList( updateList(
id: ID!, id: ID!,
title: String! title: String!
): List @bb_resolver(_type: UPDATE, _object: List, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title" }) ): 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" } }) deleteList(id: ID!): List
@bb_resolver(_type: DELETE, _object: List, _filter: { id: { _eq: "$id" } })
createTask( createTask(
title: String!, title: String!,
description: String, description: String,
completed: Boolean!, # default not implemented yet, this needs to be added as it's non-nullable completed: Boolean!,
list: List! # list needs to be specified as it's non-nullable list: ListInput!
user: User! # username needs to be specified as it's non-nullable user: UserInput!
): Task @bb_resolver(_type: INSERT, _object: Task, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list", user: "$user" }) ): Task
@bb_resolver(
_type: INSERT,
_object: Task,
_fields: {
title: "$title",
description: "$description",
completed: "$completed",
list: { id: "$list.$id" },
user: { username: "$user.$username" } })
updateTask( updateTask(
id: ID!, id: ID!,
title: String, title: String,
description: String, description: String,
completed: Boolean, completed: Boolean,
list: List list: ListInput
): Task @bb_resolver(_type: UPDATE, _object: Task, _filter: { id: { _eq: "$id" } }, _fields: { title: "$title", description: "$description", completed: "$completed", list: "$list" }) ): 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" } }) deleteTask(id: ID!): Task
@bb_resolver(
_type: DELETE,
_object: Task,
_filter: { id: { _eq: "$id" }})
} }