From 0d4fb6a0d0e2385efb20550512a6ed91c3958f9c Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Sat, 19 Sep 2020 17:26:02 -0500 Subject: [PATCH] fix: member permissions now works correctly --- .../src/Projects/Project/Details/index.tsx | 14 +- frontend/src/Projects/Project/index.tsx | 22 +- frontend/src/shared/generated/graphql.tsx | 70 +-- .../shared/graphql/createTaskGroup.graphqls | 2 +- .../src/shared/graphql/deleteTask.graphqls | 2 +- .../src/shared/graphql/task/createTask.ts | 2 +- .../task/updateTaskChecklistItemLocation.ts | 6 +- .../task/updateTaskChecklistLocation.ts | 4 +- .../shared/graphql/updateTaskName.graphqls | 2 +- internal/commands/worker.go | 3 +- internal/db/querier.go | 3 + internal/db/query/notification.sql | 1 - internal/db/query/task_checklist.sql | 13 + internal/db/query/task_group.sql | 3 + internal/db/task_checklist.sql.go | 29 ++ internal/db/task_group.sql.go | 11 + internal/graph/generated.go | 449 +++++++++--------- internal/graph/graph.go | 58 ++- internal/graph/models_gen.go | 55 ++- internal/graph/schema.graphqls | 115 ++--- internal/graph/schema.resolvers.go | 71 +-- internal/graph/schema/_root.gql | 5 +- internal/graph/schema/project_label.gql | 10 +- internal/graph/schema/task.gql | 26 +- internal/graph/schema/task_checklist.gql | 33 +- internal/graph/schema/task_group.gql | 16 +- internal/graph/schema/task_label.gql | 21 +- internal/graph/schema/user.gql | 4 +- scripts/lint.sh | 16 +- 29 files changed, 604 insertions(+), 462 deletions(-) diff --git a/frontend/src/Projects/Project/Details/index.tsx b/frontend/src/Projects/Project/Details/index.tsx index 9a69a4f..7aa9f62 100644 --- a/frontend/src/Projects/Project/Details/index.tsx +++ b/frontend/src/Projects/Project/Details/index.tsx @@ -309,7 +309,7 @@ const Details: React.FC = ({ task={data.findTask} onChecklistDrop={checklist => { updateTaskChecklistLocation({ - variables: { checklistID: checklist.id, position: checklist.position }, + variables: { taskChecklistID: checklist.id, position: checklist.position }, optimisticResponse: { __typename: 'Mutation', @@ -324,20 +324,24 @@ const Details: React.FC = ({ }, }); }} - onChecklistItemDrop={(prevChecklistID, checklistID, checklistItem) => { + onChecklistItemDrop={(prevChecklistID, taskChecklistID, checklistItem) => { updateTaskChecklistItemLocation({ - variables: { checklistID, checklistItemID: checklistItem.id, position: checklistItem.position }, + variables: { + taskChecklistID, + taskChecklistItemID: checklistItem.id, + position: checklistItem.position, + }, optimisticResponse: { __typename: 'Mutation', updateTaskChecklistItemLocation: { __typename: 'UpdateTaskChecklistItemLocationPayload', prevChecklistID, - checklistID, + taskChecklistID, checklistItem: { __typename: 'TaskChecklistItem', position: checklistItem.position, id: checklistItem.id, - taskChecklistID: checklistID, + taskChecklistID, }, }, }, diff --git a/frontend/src/Projects/Project/index.tsx b/frontend/src/Projects/Project/index.tsx index 5ca804f..6637f7d 100644 --- a/frontend/src/Projects/Project/index.tsx +++ b/frontend/src/Projects/Project/index.tsx @@ -135,7 +135,26 @@ const Project = () => { const [value, setValue] = useStateWithLocalStorage(CARD_LABEL_VARIANT_STORAGE_KEY); const [updateProjectMemberRole] = useUpdateProjectMemberRoleMutation(); - const [deleteTask] = useDeleteTaskMutation(); + const [deleteTask] = useDeleteTaskMutation({ + update: (client, resp) => + updateApolloCache( + client, + FindProjectDocument, + cache => + produce(cache, draftCache => { + const taskGroupIdx = draftCache.findProject.taskGroups.findIndex( + tg => tg.tasks.findIndex(t => t.id === resp.data.deleteTask.taskID) !== -1, + ); + + if (taskGroupIdx !== -1) { + draftCache.findProject.taskGroups[taskGroupIdx].tasks = cache.findProject.taskGroups[ + taskGroupIdx + ].tasks.filter(t => t.id !== resp.data.deleteTask.taskID); + } + }), + { projectID }, + ), + }); const [updateTaskName] = useUpdateTaskNameMutation(); @@ -284,6 +303,7 @@ const Project = () => { }} onDeleteTask={deletedTask => { deleteTask({ variables: { taskID: deletedTask.id } }); + history.push(`${match.url}/board`); }} onOpenAddLabelPopup={(task, $targetRef) => { taskLabelsRef.current = task.labels; diff --git a/frontend/src/shared/generated/graphql.tsx b/frontend/src/shared/generated/graphql.tsx index ee00ebe..f593008 100644 --- a/frontend/src/shared/generated/graphql.tsx +++ b/frontend/src/shared/generated/graphql.tsx @@ -209,7 +209,10 @@ export enum ObjectType { Org = 'ORG', Team = 'TEAM', Project = 'PROJECT', - Task = 'TASK' + Task = 'TASK', + TaskGroup = 'TASK_GROUP', + TaskChecklist = 'TASK_CHECKLIST', + TaskChecklistItem = 'TASK_CHECKLIST_ITEM' } export type Query = { @@ -588,7 +591,7 @@ export type ProjectsFilter = { }; export type FindUser = { - userId: Scalars['String']; + userID: Scalars['UUID']; }; export type FindProject = { @@ -722,7 +725,7 @@ export type UpdateProjectMemberRolePayload = { }; export type NewTask = { - taskGroupID: Scalars['String']; + taskGroupID: Scalars['UUID']; name: Scalars['String']; position: Scalars['Float']; }; @@ -765,34 +768,34 @@ export type NewTaskLocation = { }; export type DeleteTaskInput = { - taskID: Scalars['String']; + taskID: Scalars['UUID']; }; export type DeleteTaskPayload = { __typename?: 'DeleteTaskPayload'; - taskID: Scalars['String']; + taskID: Scalars['UUID']; }; export type UpdateTaskName = { - taskID: Scalars['String']; + taskID: Scalars['UUID']; name: Scalars['String']; }; export type UpdateTaskChecklistItemLocation = { - checklistID: Scalars['UUID']; - checklistItemID: Scalars['UUID']; + taskChecklistID: Scalars['UUID']; + taskChecklistItemID: Scalars['UUID']; position: Scalars['Float']; }; export type UpdateTaskChecklistItemLocationPayload = { __typename?: 'UpdateTaskChecklistItemLocationPayload'; - checklistID: Scalars['UUID']; + taskChecklistID: Scalars['UUID']; prevChecklistID: Scalars['UUID']; checklistItem: TaskChecklistItem; }; export type UpdateTaskChecklistLocation = { - checklistID: Scalars['UUID']; + taskChecklistID: Scalars['UUID']; position: Scalars['Float']; }; @@ -908,7 +911,7 @@ export type DeleteTaskGroupPayload = { }; export type NewTaskGroup = { - projectID: Scalars['String']; + projectID: Scalars['UUID']; name: Scalars['String']; position: Scalars['Float']; }; @@ -919,6 +922,7 @@ export type AddTaskLabelInput = { }; export type RemoveTaskLabelInput = { + taskID: Scalars['UUID']; taskLabelID: Scalars['UUID']; }; @@ -1020,7 +1024,7 @@ export type UpdateUserRolePayload = { }; export type NewRefreshToken = { - userId: Scalars['String']; + userID: Scalars['UUID']; }; export type NewUserAccount = { @@ -1033,7 +1037,7 @@ export type NewUserAccount = { }; export type LogoutUser = { - userID: Scalars['String']; + userID: Scalars['UUID']; }; export type DeleteUserAccount = { @@ -1119,7 +1123,7 @@ export type CreateProjectLabelMutation = ( ); export type CreateTaskGroupMutationVariables = { - projectID: Scalars['String']; + projectID: Scalars['UUID']; name: Scalars['String']; position: Scalars['Float']; }; @@ -1147,7 +1151,7 @@ export type DeleteProjectLabelMutation = ( ); export type DeleteTaskMutationVariables = { - taskID: Scalars['String']; + taskID: Scalars['UUID']; }; @@ -1472,7 +1476,7 @@ export type UpdateProjectMemberRoleMutation = ( ); export type CreateTaskMutationVariables = { - taskGroupID: Scalars['String']; + taskGroupID: Scalars['UUID']; name: Scalars['String']; position: Scalars['Float']; }; @@ -1583,8 +1587,8 @@ export type SetTaskCompleteMutation = ( ); export type UpdateTaskChecklistItemLocationMutationVariables = { - checklistID: Scalars['UUID']; - checklistItemID: Scalars['UUID']; + taskChecklistID: Scalars['UUID']; + taskChecklistItemID: Scalars['UUID']; position: Scalars['Float']; }; @@ -1593,7 +1597,7 @@ export type UpdateTaskChecklistItemLocationMutation = ( { __typename?: 'Mutation' } & { updateTaskChecklistItemLocation: ( { __typename?: 'UpdateTaskChecklistItemLocationPayload' } - & Pick + & Pick & { checklistItem: ( { __typename?: 'TaskChecklistItem' } & Pick @@ -1616,7 +1620,7 @@ export type UpdateTaskChecklistItemNameMutation = ( ); export type UpdateTaskChecklistLocationMutationVariables = { - checklistID: Scalars['UUID']; + taskChecklistID: Scalars['UUID']; position: Scalars['Float']; }; @@ -2072,7 +2076,7 @@ export type UpdateTaskLocationMutation = ( ); export type UpdateTaskNameMutationVariables = { - taskID: Scalars['String']; + taskID: Scalars['UUID']; name: Scalars['String']; }; @@ -2442,7 +2446,7 @@ export type CreateProjectLabelMutationHookResult = ReturnType; export type CreateProjectLabelMutationOptions = ApolloReactCommon.BaseMutationOptions; export const CreateTaskGroupDocument = gql` - mutation createTaskGroup($projectID: String!, $name: String!, $position: Float!) { + mutation createTaskGroup($projectID: UUID!, $name: String!, $position: Float!) { createTaskGroup(input: {projectID: $projectID, name: $name, position: $position}) { id name @@ -2510,7 +2514,7 @@ export type DeleteProjectLabelMutationHookResult = ReturnType; export type DeleteProjectLabelMutationOptions = ApolloReactCommon.BaseMutationOptions; export const DeleteTaskDocument = gql` - mutation deleteTask($taskID: String!) { + mutation deleteTask($taskID: UUID!) { deleteTask(input: {taskID: $taskID}) { taskID } @@ -3044,7 +3048,7 @@ export type UpdateProjectMemberRoleMutationHookResult = ReturnType; export type UpdateProjectMemberRoleMutationOptions = ApolloReactCommon.BaseMutationOptions; export const CreateTaskDocument = gql` - mutation createTask($taskGroupID: String!, $name: String!, $position: Float!) { + mutation createTask($taskGroupID: UUID!, $name: String!, $position: Float!) { createTask(input: {taskGroupID: $taskGroupID, name: $name, position: $position}) { ...TaskFields } @@ -3297,9 +3301,9 @@ export type SetTaskCompleteMutationHookResult = ReturnType; export type SetTaskCompleteMutationOptions = ApolloReactCommon.BaseMutationOptions; export const UpdateTaskChecklistItemLocationDocument = gql` - mutation updateTaskChecklistItemLocation($checklistID: UUID!, $checklistItemID: UUID!, $position: Float!) { - updateTaskChecklistItemLocation(input: {checklistID: $checklistID, checklistItemID: $checklistItemID, position: $position}) { - checklistID + mutation updateTaskChecklistItemLocation($taskChecklistID: UUID!, $taskChecklistItemID: UUID!, $position: Float!) { + updateTaskChecklistItemLocation(input: {taskChecklistID: $taskChecklistID, taskChecklistItemID: $taskChecklistItemID, position: $position}) { + taskChecklistID prevChecklistID checklistItem { id @@ -3324,8 +3328,8 @@ export type UpdateTaskChecklistItemLocationMutationFn = ApolloReactCommon.Mutati * @example * const [updateTaskChecklistItemLocationMutation, { data, loading, error }] = useUpdateTaskChecklistItemLocationMutation({ * variables: { - * checklistID: // value for 'checklistID' - * checklistItemID: // value for 'checklistItemID' + * taskChecklistID: // value for 'taskChecklistID' + * taskChecklistItemID: // value for 'taskChecklistItemID' * position: // value for 'position' * }, * }); @@ -3371,8 +3375,8 @@ export type UpdateTaskChecklistItemNameMutationHookResult = ReturnType; export type UpdateTaskChecklistItemNameMutationOptions = ApolloReactCommon.BaseMutationOptions; export const UpdateTaskChecklistLocationDocument = gql` - mutation updateTaskChecklistLocation($checklistID: UUID!, $position: Float!) { - updateTaskChecklistLocation(input: {checklistID: $checklistID, position: $position}) { + mutation updateTaskChecklistLocation($taskChecklistID: UUID!, $position: Float!) { + updateTaskChecklistLocation(input: {taskChecklistID: $taskChecklistID, position: $position}) { checklist { id position @@ -3395,7 +3399,7 @@ export type UpdateTaskChecklistLocationMutationFn = ApolloReactCommon.MutationFu * @example * const [updateTaskChecklistLocationMutation, { data, loading, error }] = useUpdateTaskChecklistLocationMutation({ * variables: { - * checklistID: // value for 'checklistID' + * taskChecklistID: // value for 'taskChecklistID' * position: // value for 'position' * }, * }); @@ -4275,7 +4279,7 @@ export type UpdateTaskLocationMutationHookResult = ReturnType; export type UpdateTaskLocationMutationOptions = ApolloReactCommon.BaseMutationOptions; export const UpdateTaskNameDocument = gql` - mutation updateTaskName($taskID: String!, $name: String!) { + mutation updateTaskName($taskID: UUID!, $name: String!) { updateTaskName(input: {taskID: $taskID, name: $name}) { id name diff --git a/frontend/src/shared/graphql/createTaskGroup.graphqls b/frontend/src/shared/graphql/createTaskGroup.graphqls index b168a83..bd5a6a1 100644 --- a/frontend/src/shared/graphql/createTaskGroup.graphqls +++ b/frontend/src/shared/graphql/createTaskGroup.graphqls @@ -1,4 +1,4 @@ -mutation createTaskGroup( $projectID: String!, $name: String!, $position: Float! ) { +mutation createTaskGroup( $projectID: UUID!, $name: String!, $position: Float! ) { createTaskGroup( input: { projectID: $projectID, name: $name, position: $position } ) { diff --git a/frontend/src/shared/graphql/deleteTask.graphqls b/frontend/src/shared/graphql/deleteTask.graphqls index 9c434b8..4cf404f 100644 --- a/frontend/src/shared/graphql/deleteTask.graphqls +++ b/frontend/src/shared/graphql/deleteTask.graphqls @@ -1,4 +1,4 @@ -mutation deleteTask($taskID: String!) { +mutation deleteTask($taskID: UUID!) { deleteTask(input: { taskID: $taskID }) { taskID } diff --git a/frontend/src/shared/graphql/task/createTask.ts b/frontend/src/shared/graphql/task/createTask.ts index 8dfd5d4..13dd654 100644 --- a/frontend/src/shared/graphql/task/createTask.ts +++ b/frontend/src/shared/graphql/task/createTask.ts @@ -2,7 +2,7 @@ import gql from 'graphql-tag'; import TASK_FRAGMENT from '../fragments/task'; const CREATE_TASK_MUTATION = gql` - mutation createTask($taskGroupID: String!, $name: String!, $position: Float!) { + mutation createTask($taskGroupID: UUID!, $name: String!, $position: Float!) { createTask(input: { taskGroupID: $taskGroupID, name: $name, position: $position }) { ...TaskFields } diff --git a/frontend/src/shared/graphql/task/updateTaskChecklistItemLocation.ts b/frontend/src/shared/graphql/task/updateTaskChecklistItemLocation.ts index c638c6e..e4b9c12 100644 --- a/frontend/src/shared/graphql/task/updateTaskChecklistItemLocation.ts +++ b/frontend/src/shared/graphql/task/updateTaskChecklistItemLocation.ts @@ -1,11 +1,11 @@ import gql from 'graphql-tag'; const UPDATE_TASK_CHECKLIST_ITEM_LOCATION_MUTATION = gql` - mutation updateTaskChecklistItemLocation($checklistID: UUID!, $checklistItemID: UUID!, $position: Float!) { + mutation updateTaskChecklistItemLocation($taskChecklistID: UUID!, $taskChecklistItemID: UUID!, $position: Float!) { updateTaskChecklistItemLocation( - input: { checklistID: $checklistID, checklistItemID: $checklistItemID, position: $position } + input: { taskChecklistID: $taskChecklistID, taskChecklistItemID: $taskChecklistItemID, position: $position } ) { - checklistID + taskChecklistID prevChecklistID checklistItem { id diff --git a/frontend/src/shared/graphql/task/updateTaskChecklistLocation.ts b/frontend/src/shared/graphql/task/updateTaskChecklistLocation.ts index 509b6f7..6cebafa 100644 --- a/frontend/src/shared/graphql/task/updateTaskChecklistLocation.ts +++ b/frontend/src/shared/graphql/task/updateTaskChecklistLocation.ts @@ -1,8 +1,8 @@ import gql from 'graphql-tag'; const UPDATE_TASK_CHECKLIST_LOCATION_MUTATION = gql` - mutation updateTaskChecklistLocation($checklistID: UUID!, $position: Float!) { - updateTaskChecklistLocation(input: { checklistID: $checklistID, position: $position }) { + mutation updateTaskChecklistLocation($taskChecklistID: UUID!, $position: Float!) { + updateTaskChecklistLocation(input: { taskChecklistID: $taskChecklistID, position: $position }) { checklist { id position diff --git a/frontend/src/shared/graphql/updateTaskName.graphqls b/frontend/src/shared/graphql/updateTaskName.graphqls index 5ca0b88..5821954 100644 --- a/frontend/src/shared/graphql/updateTaskName.graphqls +++ b/frontend/src/shared/graphql/updateTaskName.graphqls @@ -1,4 +1,4 @@ -mutation updateTaskName($taskID: String!, $name: String!) { +mutation updateTaskName($taskID: UUID!, $name: String!) { updateTaskName(input: { taskID: $taskID, name: $name }) { id name diff --git a/internal/commands/worker.go b/internal/commands/worker.go index 7855fb0..100ef2f 100644 --- a/internal/commands/worker.go +++ b/internal/commands/worker.go @@ -2,9 +2,10 @@ package commands import ( "fmt" + "time" + "github.com/spf13/cobra" "github.com/spf13/viper" - "time" "github.com/RichardKnop/machinery/v1" "github.com/RichardKnop/machinery/v1/config" diff --git a/internal/db/querier.go b/internal/db/querier.go index 8f47d16..665296d 100644 --- a/internal/db/querier.go +++ b/internal/db/querier.go @@ -64,6 +64,9 @@ type Querier interface { GetNotificationForNotificationID(ctx context.Context, notificationID uuid.UUID) (GetNotificationForNotificationIDRow, error) GetProjectByID(ctx context.Context, projectID uuid.UUID) (Project, error) GetProjectIDForTask(ctx context.Context, taskID uuid.UUID) (uuid.UUID, error) + GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error) + GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error) + GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error) GetProjectLabelByID(ctx context.Context, projectLabelID uuid.UUID) (ProjectLabel, error) GetProjectLabelsForProject(ctx context.Context, projectID uuid.UUID) ([]ProjectLabel, error) GetProjectMembersForProjectID(ctx context.Context, projectID uuid.UUID) ([]ProjectMember, error) diff --git a/internal/db/query/notification.sql b/internal/db/query/notification.sql index c8c86ad..4347126 100644 --- a/internal/db/query/notification.sql +++ b/internal/db/query/notification.sql @@ -25,4 +25,3 @@ WHERE n.notification_id = $1; -- name: CreateNotification :one INSERT INTO notification(notification_object_id, notifier_id) VALUES ($1, $2) RETURNING *; - diff --git a/internal/db/query/task_checklist.sql b/internal/db/query/task_checklist.sql index a75eb72..2163629 100644 --- a/internal/db/query/task_checklist.sql +++ b/internal/db/query/task_checklist.sql @@ -41,3 +41,16 @@ UPDATE task_checklist SET position = $2 WHERE task_checklist_id = $1 RETURNING * -- name: UpdateTaskChecklistItemLocation :one UPDATE task_checklist_item SET position = $2, task_checklist_id = $3 WHERE task_checklist_item_id = $1 RETURNING *; + +-- name: GetProjectIDForTaskChecklist :one +SELECT project_id FROM task_checklist + INNER JOIN task ON task.task_id = task_checklist.task_id + INNER JOIN task_group ON task_group.task_group_id = task.task_group_id + WHERE task_checklist.task_checklist_id = $1; + +-- name: GetProjectIDForTaskChecklistItem :one +SELECT project_id FROM task_checklist_item AS tci + INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id + INNER JOIN task ON task.task_id = task_checklist.task_id + INNER JOIN task_group ON task_group.task_group_id = task.task_group_id + WHERE tci.task_checklist_item_id = $1; diff --git a/internal/db/query/task_group.sql b/internal/db/query/task_group.sql index 91443c6..b36f519 100644 --- a/internal/db/query/task_group.sql +++ b/internal/db/query/task_group.sql @@ -5,6 +5,9 @@ INSERT INTO task_group (project_id, created_at, name, position) -- name: GetTaskGroupsForProject :many SELECT * FROM task_group WHERE project_id = $1; +-- name: GetProjectIDForTaskGroup :one +SELECT project_id from task_group WHERE task_group_id = $1; + -- name: GetAllTaskGroups :many SELECT * FROM task_group; diff --git a/internal/db/task_checklist.sql.go b/internal/db/task_checklist.sql.go index d975316..765b222 100644 --- a/internal/db/task_checklist.sql.go +++ b/internal/db/task_checklist.sql.go @@ -90,6 +90,35 @@ func (q *Queries) DeleteTaskChecklistItem(ctx context.Context, taskChecklistItem return err } +const getProjectIDForTaskChecklist = `-- name: GetProjectIDForTaskChecklist :one +SELECT project_id FROM task_checklist + INNER JOIN task ON task.task_id = task_checklist.task_id + INNER JOIN task_group ON task_group.task_group_id = task.task_group_id + WHERE task_checklist.task_checklist_id = $1 +` + +func (q *Queries) GetProjectIDForTaskChecklist(ctx context.Context, taskChecklistID uuid.UUID) (uuid.UUID, error) { + row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklist, taskChecklistID) + var project_id uuid.UUID + err := row.Scan(&project_id) + return project_id, err +} + +const getProjectIDForTaskChecklistItem = `-- name: GetProjectIDForTaskChecklistItem :one +SELECT project_id FROM task_checklist_item AS tci + INNER JOIN task_checklist ON task_checklist.task_checklist_id = tci.task_checklist_id + INNER JOIN task ON task.task_id = task_checklist.task_id + INNER JOIN task_group ON task_group.task_group_id = task.task_group_id + WHERE tci.task_checklist_item_id = $1 +` + +func (q *Queries) GetProjectIDForTaskChecklistItem(ctx context.Context, taskChecklistItemID uuid.UUID) (uuid.UUID, error) { + row := q.db.QueryRowContext(ctx, getProjectIDForTaskChecklistItem, taskChecklistItemID) + var project_id uuid.UUID + err := row.Scan(&project_id) + return project_id, err +} + const getTaskChecklistByID = `-- name: GetTaskChecklistByID :one SELECT task_checklist_id, task_id, created_at, name, position FROM task_checklist WHERE task_checklist_id = $1 ` diff --git a/internal/db/task_group.sql.go b/internal/db/task_group.sql.go index cf22e19..a43b029 100644 --- a/internal/db/task_group.sql.go +++ b/internal/db/task_group.sql.go @@ -85,6 +85,17 @@ func (q *Queries) GetAllTaskGroups(ctx context.Context) ([]TaskGroup, error) { return items, nil } +const getProjectIDForTaskGroup = `-- name: GetProjectIDForTaskGroup :one +SELECT project_id from task_group WHERE task_group_id = $1 +` + +func (q *Queries) GetProjectIDForTaskGroup(ctx context.Context, taskGroupID uuid.UUID) (uuid.UUID, error) { + row := q.db.QueryRowContext(ctx, getProjectIDForTaskGroup, taskGroupID) + var project_id uuid.UUID + err := row.Scan(&project_id) + return project_id, err +} + const getTaskGroupByID = `-- name: GetTaskGroupByID :one SELECT task_group_id, project_id, created_at, name, position FROM task_group WHERE task_group_id = $1 ` diff --git a/internal/graph/generated.go b/internal/graph/generated.go index 98ab511..788c5f4 100644 --- a/internal/graph/generated.go +++ b/internal/graph/generated.go @@ -385,9 +385,9 @@ type ComplexityRoot struct { } UpdateTaskChecklistItemLocationPayload struct { - ChecklistID func(childComplexity int) int ChecklistItem func(childComplexity int) int PrevChecklistID func(childComplexity int) int + TaskChecklistID func(childComplexity int) int } UpdateTaskChecklistLocationPayload struct { @@ -461,10 +461,10 @@ type MutationResolver interface { DeleteTaskChecklist(ctx context.Context, input DeleteTaskChecklist) (*DeleteTaskChecklistPayload, error) UpdateTaskChecklistName(ctx context.Context, input UpdateTaskChecklistName) (*db.TaskChecklist, error) CreateTaskChecklistItem(ctx context.Context, input CreateTaskChecklistItem) (*db.TaskChecklistItem, error) + UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) UpdateTaskChecklistItemName(ctx context.Context, input UpdateTaskChecklistItemName) (*db.TaskChecklistItem, error) SetTaskChecklistItemComplete(ctx context.Context, input SetTaskChecklistItemComplete) (*db.TaskChecklistItem, error) DeleteTaskChecklistItem(ctx context.Context, input DeleteTaskChecklistItem) (*DeleteTaskChecklistItemPayload, error) - UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) UpdateTaskChecklistItemLocation(ctx context.Context, input UpdateTaskChecklistItemLocation) (*UpdateTaskChecklistItemLocationPayload, error) CreateTaskGroup(ctx context.Context, input NewTaskGroup) (*db.TaskGroup, error) UpdateTaskGroupLocation(ctx context.Context, input NewTaskGroupLocation) (*db.TaskGroup, error) @@ -2240,13 +2240,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UpdateProjectMemberRolePayload.Ok(childComplexity), true - case "UpdateTaskChecklistItemLocationPayload.checklistID": - if e.complexity.UpdateTaskChecklistItemLocationPayload.ChecklistID == nil { - break - } - - return e.complexity.UpdateTaskChecklistItemLocationPayload.ChecklistID(childComplexity), true - case "UpdateTaskChecklistItemLocationPayload.checklistItem": if e.complexity.UpdateTaskChecklistItemLocationPayload.ChecklistItem == nil { break @@ -2261,6 +2254,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.UpdateTaskChecklistItemLocationPayload.PrevChecklistID(childComplexity), true + case "UpdateTaskChecklistItemLocationPayload.taskChecklistID": + if e.complexity.UpdateTaskChecklistItemLocationPayload.TaskChecklistID == nil { + break + } + + return e.complexity.UpdateTaskChecklistItemLocationPayload.TaskChecklistID(childComplexity), true + case "UpdateTaskChecklistLocationPayload.checklist": if e.complexity.UpdateTaskChecklistLocationPayload.Checklist == nil { break @@ -2648,6 +2648,9 @@ enum ObjectType { TEAM PROJECT TASK + TASK_GROUP + TASK_CHECKLIST + TASK_CHECKLIST_ITEM } directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!) on FIELD_DEFINITION @@ -2689,7 +2692,7 @@ input ProjectsFilter { } input FindUser { - userId: String! + userID: UUID! } input FindProject { @@ -2771,15 +2774,15 @@ type DeleteProjectPayload { extend type Mutation { createProjectLabel(input: NewProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) deleteProjectLabel(input: DeleteProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabel(input: UpdateProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelName(input: UpdateProjectLabelName!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelColor(input: UpdateProjectLabelColor!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) } input NewProjectLabel { @@ -2851,29 +2854,29 @@ type UpdateProjectMemberRolePayload { extend type Mutation { createTask(input: NewTask!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTask(input: DeleteTaskInput!): - DeleteTaskPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDescription(input: UpdateTaskDescriptionInput!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskLocation(input: NewTaskLocation!): - UpdateTaskLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskName(input: UpdateTaskName!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) setTaskComplete(input: SetTaskComplete!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDueDate(input: UpdateTaskDueDate!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) assignTask(input: AssignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) unassignTask(input: UnassignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) } input NewTask { - taskGroupID: String! + taskGroupID: UUID! name: String! position: Float! } @@ -2915,54 +2918,55 @@ input NewTaskLocation { } input DeleteTaskInput { - taskID: String! + taskID: UUID! } type DeleteTaskPayload { - taskID: String! + taskID: UUID! } input UpdateTaskName { - taskID: String! + taskID: UUID! name: String! } extend type Mutation { createTaskChecklist(input: CreateTaskChecklist!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) deleteTaskChecklist(input: DeleteTaskChecklist!): - DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistName(input: UpdateTaskChecklistName!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) createTaskChecklistItem(input: CreateTaskChecklistItem!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): - DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!): - UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) + + updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): + DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!): - UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) } input UpdateTaskChecklistItemLocation { - checklistID: UUID! - checklistItemID: UUID! + taskChecklistID: UUID! + taskChecklistItemID: UUID! position: Float! } type UpdateTaskChecklistItemLocationPayload { - checklistID: UUID! + taskChecklistID: UUID! prevChecklistID: UUID! checklistItem: TaskChecklistItem! } input UpdateTaskChecklistLocation { - checklistID: UUID! + taskChecklistID: UUID! position: Float! } @@ -3015,19 +3019,19 @@ type DeleteTaskChecklistPayload { extend type Mutation { createTaskGroup(input: NewTaskGroup!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateTaskGroupLocation(input: NewTaskGroupLocation!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) updateTaskGroupName(input: UpdateTaskGroupName!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroup(input: DeleteTaskGroupInput!): - DeleteTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) duplicateTaskGroup(input: DuplicateTaskGroup!): - DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) sortTaskGroup(input: SortTaskGroup!): - SortTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + SortTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroupTasks(input: DeleteTaskGroupTasks!): - DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) } input DeleteTaskGroupTasks { @@ -3086,19 +3090,31 @@ type DeleteTaskGroupPayload { } input NewTaskGroup { - projectID: String! + projectID: UUID! name: String! position: Float! } +extend type Mutation { + addTaskLabel(input: AddTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + removeTaskLabel(input: RemoveTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + toggleTaskLabel(input: ToggleTaskLabelInput!): + ToggleTaskLabelPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + +} + input AddTaskLabelInput { taskID: UUID! projectLabelID: UUID! } input RemoveTaskLabelInput { + taskID: UUID! taskLabelID: UUID! } + input ToggleTaskLabelInput { taskID: UUID! projectLabelID: UUID! @@ -3108,15 +3124,6 @@ type ToggleTaskLabelPayload { active: Boolean! task: Task! } -extend type Mutation { - addTaskLabel(input: AddTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - removeTaskLabel(input: RemoveTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - toggleTaskLabel(input: ToggleTaskLabelInput!): - ToggleTaskLabelPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - -} extend type Mutation { deleteTeam(input: DeleteTeam!): @@ -3232,7 +3239,7 @@ type UpdateUserRolePayload { } input NewRefreshToken { - userId: String! + userID: UUID! } input NewUserAccount { @@ -3245,7 +3252,7 @@ input NewUserAccount { } input LogoutUser { - userID: String! + userID: UUID! } input DeleteUserAccount { @@ -4839,9 +4846,9 @@ func (ec *executionContext) _DeleteTaskPayload_taskID(ctx context.Context, field } return graphql.Null } - res := resTmp.(string) + res := resTmp.(uuid.UUID) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, field.Selections, res) } func (ec *executionContext) _DeleteTeamMemberPayload_teamID(ctx context.Context, field graphql.CollectedField, obj *DeleteTeamMemberPayload) (ret graphql.Marshaler) { @@ -5941,7 +5948,7 @@ func (ec *executionContext) _Mutation_createProjectLabel(ctx context.Context, fi return ec.resolvers.Mutation().CreateProjectLabel(rctx, args["input"].(NewProjectLabel)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6014,7 +6021,7 @@ func (ec *executionContext) _Mutation_deleteProjectLabel(ctx context.Context, fi return ec.resolvers.Mutation().DeleteProjectLabel(rctx, args["input"].(DeleteProjectLabel)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6087,7 +6094,7 @@ func (ec *executionContext) _Mutation_updateProjectLabel(ctx context.Context, fi return ec.resolvers.Mutation().UpdateProjectLabel(rctx, args["input"].(UpdateProjectLabel)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6160,7 +6167,7 @@ func (ec *executionContext) _Mutation_updateProjectLabelName(ctx context.Context return ec.resolvers.Mutation().UpdateProjectLabelName(rctx, args["input"].(UpdateProjectLabelName)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6233,7 +6240,7 @@ func (ec *executionContext) _Mutation_updateProjectLabelColor(ctx context.Contex return ec.resolvers.Mutation().UpdateProjectLabelColor(rctx, args["input"].(UpdateProjectLabelColor)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6525,7 +6532,7 @@ func (ec *executionContext) _Mutation_createTask(ctx context.Context, field grap return ec.resolvers.Mutation().CreateTask(rctx, args["input"].(NewTask)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6533,7 +6540,7 @@ func (ec *executionContext) _Mutation_createTask(ctx context.Context, field grap if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -6598,7 +6605,7 @@ func (ec *executionContext) _Mutation_deleteTask(ctx context.Context, field grap return ec.resolvers.Mutation().DeleteTask(rctx, args["input"].(DeleteTaskInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6606,7 +6613,7 @@ func (ec *executionContext) _Mutation_deleteTask(ctx context.Context, field grap if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -6671,7 +6678,7 @@ func (ec *executionContext) _Mutation_updateTaskDescription(ctx context.Context, return ec.resolvers.Mutation().UpdateTaskDescription(rctx, args["input"].(UpdateTaskDescriptionInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6679,7 +6686,7 @@ func (ec *executionContext) _Mutation_updateTaskDescription(ctx context.Context, if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -6744,7 +6751,7 @@ func (ec *executionContext) _Mutation_updateTaskLocation(ctx context.Context, fi return ec.resolvers.Mutation().UpdateTaskLocation(rctx, args["input"].(NewTaskLocation)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6752,7 +6759,7 @@ func (ec *executionContext) _Mutation_updateTaskLocation(ctx context.Context, fi if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -6817,7 +6824,7 @@ func (ec *executionContext) _Mutation_updateTaskName(ctx context.Context, field return ec.resolvers.Mutation().UpdateTaskName(rctx, args["input"].(UpdateTaskName)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6825,7 +6832,7 @@ func (ec *executionContext) _Mutation_updateTaskName(ctx context.Context, field if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -6890,7 +6897,7 @@ func (ec *executionContext) _Mutation_setTaskComplete(ctx context.Context, field return ec.resolvers.Mutation().SetTaskComplete(rctx, args["input"].(SetTaskComplete)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6898,7 +6905,7 @@ func (ec *executionContext) _Mutation_setTaskComplete(ctx context.Context, field if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -6963,7 +6970,7 @@ func (ec *executionContext) _Mutation_updateTaskDueDate(ctx context.Context, fie return ec.resolvers.Mutation().UpdateTaskDueDate(rctx, args["input"].(UpdateTaskDueDate)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -6971,7 +6978,7 @@ func (ec *executionContext) _Mutation_updateTaskDueDate(ctx context.Context, fie if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -7036,7 +7043,7 @@ func (ec *executionContext) _Mutation_assignTask(ctx context.Context, field grap return ec.resolvers.Mutation().AssignTask(rctx, args["input"].(*AssignTaskInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7109,7 +7116,7 @@ func (ec *executionContext) _Mutation_unassignTask(ctx context.Context, field gr return ec.resolvers.Mutation().UnassignTask(rctx, args["input"].(*UnassignTaskInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7182,7 +7189,7 @@ func (ec *executionContext) _Mutation_createTaskChecklist(ctx context.Context, f return ec.resolvers.Mutation().CreateTaskChecklist(rctx, args["input"].(CreateTaskChecklist)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7190,7 +7197,7 @@ func (ec *executionContext) _Mutation_createTaskChecklist(ctx context.Context, f if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -7255,7 +7262,7 @@ func (ec *executionContext) _Mutation_deleteTaskChecklist(ctx context.Context, f return ec.resolvers.Mutation().DeleteTaskChecklist(rctx, args["input"].(DeleteTaskChecklist)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7263,7 +7270,7 @@ func (ec *executionContext) _Mutation_deleteTaskChecklist(ctx context.Context, f if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST") if err != nil { return nil, err } @@ -7328,7 +7335,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistName(ctx context.Contex return ec.resolvers.Mutation().UpdateTaskChecklistName(rctx, args["input"].(UpdateTaskChecklistName)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7336,7 +7343,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistName(ctx context.Contex if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST") if err != nil { return nil, err } @@ -7401,7 +7408,7 @@ func (ec *executionContext) _Mutation_createTaskChecklistItem(ctx context.Contex return ec.resolvers.Mutation().CreateTaskChecklistItem(rctx, args["input"].(CreateTaskChecklistItem)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7409,7 +7416,7 @@ func (ec *executionContext) _Mutation_createTaskChecklistItem(ctx context.Contex if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST") if err != nil { return nil, err } @@ -7446,6 +7453,79 @@ func (ec *executionContext) _Mutation_createTaskChecklistItem(ctx context.Contex return ec.marshalNTaskChecklistItem2ᚖgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋdbᚐTaskChecklistItem(ctx, field.Selections, res) } +func (ec *executionContext) _Mutation_updateTaskChecklistLocation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Mutation", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + rawArgs := field.ArgumentMap(ec.Variables) + args, err := ec.field_Mutation_updateTaskChecklistLocation_args(ctx, rawArgs) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + fc.Args = args + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().UpdateTaskChecklistLocation(rctx, args["input"].(UpdateTaskChecklistLocation)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) + if err != nil { + return nil, err + } + level, err := ec.unmarshalNActionLevel2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐActionLevel(ctx, "PROJECT") + if err != nil { + return nil, err + } + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST") + if err != nil { + return nil, err + } + if ec.directives.HasRole == nil { + return nil, errors.New("directive hasRole is not implemented") + } + return ec.directives.HasRole(ctx, nil, directive0, roles, level, typeArg) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, err + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*UpdateTaskChecklistLocationPayload); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/jordanknott/taskcafe/internal/graph.UpdateTaskChecklistLocationPayload`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*UpdateTaskChecklistLocationPayload) + fc.Result = res + return ec.marshalNUpdateTaskChecklistLocationPayload2ᚖgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐUpdateTaskChecklistLocationPayload(ctx, field.Selections, res) +} + func (ec *executionContext) _Mutation_updateTaskChecklistItemName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -7474,7 +7554,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistItemName(ctx context.Co return ec.resolvers.Mutation().UpdateTaskChecklistItemName(rctx, args["input"].(UpdateTaskChecklistItemName)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7482,7 +7562,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistItemName(ctx context.Co if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST_ITEM") if err != nil { return nil, err } @@ -7547,7 +7627,7 @@ func (ec *executionContext) _Mutation_setTaskChecklistItemComplete(ctx context.C return ec.resolvers.Mutation().SetTaskChecklistItemComplete(rctx, args["input"].(SetTaskChecklistItemComplete)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7555,7 +7635,7 @@ func (ec *executionContext) _Mutation_setTaskChecklistItemComplete(ctx context.C if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST_ITEM") if err != nil { return nil, err } @@ -7620,7 +7700,7 @@ func (ec *executionContext) _Mutation_deleteTaskChecklistItem(ctx context.Contex return ec.resolvers.Mutation().DeleteTaskChecklistItem(rctx, args["input"].(DeleteTaskChecklistItem)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7628,7 +7708,7 @@ func (ec *executionContext) _Mutation_deleteTaskChecklistItem(ctx context.Contex if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST_ITEM") if err != nil { return nil, err } @@ -7665,79 +7745,6 @@ func (ec *executionContext) _Mutation_deleteTaskChecklistItem(ctx context.Contex return ec.marshalNDeleteTaskChecklistItemPayload2ᚖgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐDeleteTaskChecklistItemPayload(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_updateTaskChecklistLocation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Mutation", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_updateTaskChecklistLocation_args(ctx, rawArgs) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - fc.Args = args - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - directive0 := func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().UpdateTaskChecklistLocation(rctx, args["input"].(UpdateTaskChecklistLocation)) - } - directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) - if err != nil { - return nil, err - } - level, err := ec.unmarshalNActionLevel2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐActionLevel(ctx, "PROJECT") - if err != nil { - return nil, err - } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") - if err != nil { - return nil, err - } - if ec.directives.HasRole == nil { - return nil, errors.New("directive hasRole is not implemented") - } - return ec.directives.HasRole(ctx, nil, directive0, roles, level, typeArg) - } - - tmp, err := directive1(rctx) - if err != nil { - return nil, err - } - if tmp == nil { - return nil, nil - } - if data, ok := tmp.(*UpdateTaskChecklistLocationPayload); ok { - return data, nil - } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/jordanknott/taskcafe/internal/graph.UpdateTaskChecklistLocationPayload`, tmp) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*UpdateTaskChecklistLocationPayload) - fc.Result = res - return ec.marshalNUpdateTaskChecklistLocationPayload2ᚖgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐUpdateTaskChecklistLocationPayload(ctx, field.Selections, res) -} - func (ec *executionContext) _Mutation_updateTaskChecklistItemLocation(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -7766,7 +7773,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistItemLocation(ctx contex return ec.resolvers.Mutation().UpdateTaskChecklistItemLocation(rctx, args["input"].(UpdateTaskChecklistItemLocation)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7774,7 +7781,7 @@ func (ec *executionContext) _Mutation_updateTaskChecklistItemLocation(ctx contex if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_CHECKLIST_ITEM") if err != nil { return nil, err } @@ -7839,7 +7846,7 @@ func (ec *executionContext) _Mutation_createTaskGroup(ctx context.Context, field return ec.resolvers.Mutation().CreateTaskGroup(rctx, args["input"].(NewTaskGroup)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7912,7 +7919,7 @@ func (ec *executionContext) _Mutation_updateTaskGroupLocation(ctx context.Contex return ec.resolvers.Mutation().UpdateTaskGroupLocation(rctx, args["input"].(NewTaskGroupLocation)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7920,7 +7927,7 @@ func (ec *executionContext) _Mutation_updateTaskGroupLocation(ctx context.Contex if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -7985,7 +7992,7 @@ func (ec *executionContext) _Mutation_updateTaskGroupName(ctx context.Context, f return ec.resolvers.Mutation().UpdateTaskGroupName(rctx, args["input"].(UpdateTaskGroupName)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -7993,7 +8000,7 @@ func (ec *executionContext) _Mutation_updateTaskGroupName(ctx context.Context, f if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -8058,7 +8065,7 @@ func (ec *executionContext) _Mutation_deleteTaskGroup(ctx context.Context, field return ec.resolvers.Mutation().DeleteTaskGroup(rctx, args["input"].(DeleteTaskGroupInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8066,7 +8073,7 @@ func (ec *executionContext) _Mutation_deleteTaskGroup(ctx context.Context, field if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -8131,7 +8138,7 @@ func (ec *executionContext) _Mutation_duplicateTaskGroup(ctx context.Context, fi return ec.resolvers.Mutation().DuplicateTaskGroup(rctx, args["input"].(DuplicateTaskGroup)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8139,7 +8146,7 @@ func (ec *executionContext) _Mutation_duplicateTaskGroup(ctx context.Context, fi if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -8204,7 +8211,7 @@ func (ec *executionContext) _Mutation_sortTaskGroup(ctx context.Context, field g return ec.resolvers.Mutation().SortTaskGroup(rctx, args["input"].(SortTaskGroup)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8212,7 +8219,7 @@ func (ec *executionContext) _Mutation_sortTaskGroup(ctx context.Context, field g if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -8277,7 +8284,7 @@ func (ec *executionContext) _Mutation_deleteTaskGroupTasks(ctx context.Context, return ec.resolvers.Mutation().DeleteTaskGroupTasks(rctx, args["input"].(DeleteTaskGroupTasks)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8285,7 +8292,7 @@ func (ec *executionContext) _Mutation_deleteTaskGroupTasks(ctx context.Context, if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK_GROUP") if err != nil { return nil, err } @@ -8350,7 +8357,7 @@ func (ec *executionContext) _Mutation_addTaskLabel(ctx context.Context, field gr return ec.resolvers.Mutation().AddTaskLabel(rctx, args["input"].(*AddTaskLabelInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8358,7 +8365,7 @@ func (ec *executionContext) _Mutation_addTaskLabel(ctx context.Context, field gr if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -8423,7 +8430,7 @@ func (ec *executionContext) _Mutation_removeTaskLabel(ctx context.Context, field return ec.resolvers.Mutation().RemoveTaskLabel(rctx, args["input"].(*RemoveTaskLabelInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8431,7 +8438,7 @@ func (ec *executionContext) _Mutation_removeTaskLabel(ctx context.Context, field if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -8496,7 +8503,7 @@ func (ec *executionContext) _Mutation_toggleTaskLabel(ctx context.Context, field return ec.resolvers.Mutation().ToggleTaskLabel(rctx, args["input"].(ToggleTaskLabelInput)) } directive1 := func(ctx context.Context) (interface{}, error) { - roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN"}) + roles, err := ec.unmarshalNRoleLevel2ᚕgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐRoleLevelᚄ(ctx, []interface{}{"ADMIN", "MEMBER"}) if err != nil { return nil, err } @@ -8504,7 +8511,7 @@ func (ec *executionContext) _Mutation_toggleTaskLabel(ctx context.Context, field if err != nil { return nil, err } - typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "PROJECT") + typeArg, err := ec.unmarshalNObjectType2githubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐObjectType(ctx, "TASK") if err != nil { return nil, err } @@ -12733,7 +12740,7 @@ func (ec *executionContext) _UpdateProjectMemberRolePayload_member(ctx context.C return ec.marshalNMember2ᚖgithubᚗcomᚋjordanknottᚋtaskcafeᚋinternalᚋgraphᚐMember(ctx, field.Selections, res) } -func (ec *executionContext) _UpdateTaskChecklistItemLocationPayload_checklistID(ctx context.Context, field graphql.CollectedField, obj *UpdateTaskChecklistItemLocationPayload) (ret graphql.Marshaler) { +func (ec *executionContext) _UpdateTaskChecklistItemLocationPayload_taskChecklistID(ctx context.Context, field graphql.CollectedField, obj *UpdateTaskChecklistItemLocationPayload) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -12750,7 +12757,7 @@ func (ec *executionContext) _UpdateTaskChecklistItemLocationPayload_checklistID( ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.ChecklistID, nil + return obj.TaskChecklistID, nil }) if err != nil { ec.Error(ctx, err) @@ -14900,7 +14907,7 @@ func (ec *executionContext) unmarshalInputDeleteTaskInput(ctx context.Context, o switch k { case "taskID": var err error - it.TaskID, err = ec.unmarshalNString2string(ctx, v) + it.TaskID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15078,9 +15085,9 @@ func (ec *executionContext) unmarshalInputFindUser(ctx context.Context, obj inte for k, v := range asMap { switch k { - case "userId": + case "userID": var err error - it.UserID, err = ec.unmarshalNString2string(ctx, v) + it.UserID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15098,7 +15105,7 @@ func (ec *executionContext) unmarshalInputLogoutUser(ctx context.Context, obj in switch k { case "userID": var err error - it.UserID, err = ec.unmarshalNString2string(ctx, v) + it.UserID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15174,9 +15181,9 @@ func (ec *executionContext) unmarshalInputNewRefreshToken(ctx context.Context, o for k, v := range asMap { switch k { - case "userId": + case "userID": var err error - it.UserID, err = ec.unmarshalNString2string(ctx, v) + it.UserID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15194,7 +15201,7 @@ func (ec *executionContext) unmarshalInputNewTask(ctx context.Context, obj inter switch k { case "taskGroupID": var err error - it.TaskGroupID, err = ec.unmarshalNString2string(ctx, v) + it.TaskGroupID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15224,7 +15231,7 @@ func (ec *executionContext) unmarshalInputNewTaskGroup(ctx context.Context, obj switch k { case "projectID": var err error - it.ProjectID, err = ec.unmarshalNString2string(ctx, v) + it.ProjectID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15396,6 +15403,12 @@ func (ec *executionContext) unmarshalInputRemoveTaskLabelInput(ctx context.Conte for k, v := range asMap { switch k { + case "taskID": + var err error + it.TaskID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + if err != nil { + return it, err + } case "taskLabelID": var err error it.TaskLabelID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) @@ -15690,15 +15703,15 @@ func (ec *executionContext) unmarshalInputUpdateTaskChecklistItemLocation(ctx co for k, v := range asMap { switch k { - case "checklistID": + case "taskChecklistID": var err error - it.ChecklistID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + it.TaskChecklistID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } - case "checklistItemID": + case "taskChecklistItemID": var err error - it.ChecklistItemID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + it.TaskChecklistItemID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15744,9 +15757,9 @@ func (ec *executionContext) unmarshalInputUpdateTaskChecklistLocation(ctx contex for k, v := range asMap { switch k { - case "checklistID": + case "taskChecklistID": var err error - it.ChecklistID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) + it.TaskChecklistID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -15866,7 +15879,7 @@ func (ec *executionContext) unmarshalInputUpdateTaskName(ctx context.Context, ob switch k { case "taskID": var err error - it.TaskID, err = ec.unmarshalNString2string(ctx, v) + it.TaskID, err = ec.unmarshalNUUID2githubᚗcomᚋgoogleᚋuuidᚐUUID(ctx, v) if err != nil { return it, err } @@ -16774,6 +16787,11 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } + case "updateTaskChecklistLocation": + out.Values[i] = ec._Mutation_updateTaskChecklistLocation(ctx, field) + if out.Values[i] == graphql.Null { + invalids++ + } case "updateTaskChecklistItemName": out.Values[i] = ec._Mutation_updateTaskChecklistItemName(ctx, field) if out.Values[i] == graphql.Null { @@ -16789,11 +16807,6 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { invalids++ } - case "updateTaskChecklistLocation": - out.Values[i] = ec._Mutation_updateTaskChecklistLocation(ctx, field) - if out.Values[i] == graphql.Null { - invalids++ - } case "updateTaskChecklistItemLocation": out.Values[i] = ec._Mutation_updateTaskChecklistItemLocation(ctx, field) if out.Values[i] == graphql.Null { @@ -18356,8 +18369,8 @@ func (ec *executionContext) _UpdateTaskChecklistItemLocationPayload(ctx context. switch field.Name { case "__typename": out.Values[i] = graphql.MarshalString("UpdateTaskChecklistItemLocationPayload") - case "checklistID": - out.Values[i] = ec._UpdateTaskChecklistItemLocationPayload_checklistID(ctx, field, obj) + case "taskChecklistID": + out.Values[i] = ec._UpdateTaskChecklistItemLocationPayload_taskChecklistID(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } diff --git a/internal/graph/graph.go b/internal/graph/graph.go index f1a4909..462c347 100644 --- a/internal/graph/graph.go +++ b/internal/graph/graph.go @@ -51,31 +51,56 @@ func NewHandler(repo db.Repository) http.Handler { fieldName = "TeamID" case ObjectTypeTask: fieldName = "TaskID" + case ObjectTypeTaskGroup: + fieldName = "TaskGroupID" + case ObjectTypeTaskChecklist: + fieldName = "TaskChecklistID" + case ObjectTypeTaskChecklistItem: + fieldName = "TaskChecklistItemID" default: fieldName = "ProjectID" } log.WithFields(log.Fields{"typeArg": typeArg, "fieldName": fieldName}).Info("getting field by name") - subjectID, ok = val.FieldByName(fieldName).Interface().(uuid.UUID) + subjectField := val.FieldByName(fieldName) + if !subjectField.IsValid() { + log.Error("subject field name does not exist on input type") + return nil, errors.New("subject field name does not exist on input type") + } + subjectID, ok = subjectField.Interface().(uuid.UUID) if !ok { + log.Error("error while casting subject UUID") return nil, errors.New("error while casting subject uuid") } var err error if level == ActionLevelProject { + log.WithFields(log.Fields{"subjectID": subjectID}).Info("fetching subject ID by typeArg") if typeArg == ObjectTypeTask { - log.WithFields(log.Fields{"subjectID": subjectID}).Info("fetching project ID using task ID") subjectID, err = repo.GetProjectIDForTask(ctx, subjectID) - if err != nil { - return nil, err - } } - roles, err := GetProjectRoles(ctx, repo, subjectID) + if typeArg == ObjectTypeTaskGroup { + subjectID, err = repo.GetProjectIDForTaskGroup(ctx, subjectID) + } + if typeArg == ObjectTypeTaskChecklist { + subjectID, err = repo.GetProjectIDForTaskChecklist(ctx, subjectID) + } + if typeArg == ObjectTypeTaskChecklistItem { + subjectID, err = repo.GetProjectIDForTaskChecklistItem(ctx, subjectID) + } if err != nil { + log.WithError(err).Error("error while getting subject ID") return nil, err } - if roles.TeamRole == "admin" || roles.ProjectRole == "admin" { - log.WithFields(log.Fields{"teamRole": roles.TeamRole, "projectRole": roles.ProjectRole}).Info("is team or project role") - return next(ctx) + projectRoles, err := GetProjectRoles(ctx, repo, subjectID) + if err != nil { + log.WithError(err).Error("error while getting project roles") + return nil, err + } + for _, validRole := range roles { + if GetRoleLevel(projectRoles.TeamRole) == validRole || GetRoleLevel(projectRoles.ProjectRole) == validRole { + log.WithFields(log.Fields{"teamRole": projectRoles.TeamRole, "projectRole": projectRoles.ProjectRole}).Info("is team or project role") + return next(ctx) + } } return nil, errors.New("must be a team or project admin") } else if level == ActionLevelTeam { @@ -85,10 +110,13 @@ func NewHandler(repo db.Repository) http.Handler { } role, err := repo.GetTeamRoleForUserID(ctx, db.GetTeamRoleForUserIDParams{UserID: userID, TeamID: subjectID}) if err != nil { + log.WithError(err).Error("error while getting team roles for user ID") return nil, err } - if role.RoleCode == "admin" { - return next(ctx) + for _, validRole := range roles { + if GetRoleLevel(role.RoleCode) == validRole || GetRoleLevel(role.RoleCode) == validRole { + return next(ctx) + } } return nil, errors.New("must be a team admin") @@ -156,6 +184,14 @@ func GetProjectRoles(ctx context.Context, r db.Repository, projectID uuid.UUID) return r.GetUserRolesForProject(ctx, db.GetUserRolesForProjectParams{UserID: userID, ProjectID: projectID}) } +// GetRoleLevel converts a role level string to a RoleLevel type +func GetRoleLevel(r string) RoleLevel { + if r == RoleLevelAdmin.String() { + return RoleLevelAdmin + } + return RoleLevelMember +} + // ConvertToRoleCode converts a role code string to a RoleCode type func ConvertToRoleCode(r string) RoleCode { if r == RoleCodeAdmin.String() { diff --git a/internal/graph/models_gen.go b/internal/graph/models_gen.go index cbd47ef..bdc5255 100644 --- a/internal/graph/models_gen.go +++ b/internal/graph/models_gen.go @@ -121,11 +121,11 @@ type DeleteTaskGroupTasksPayload struct { } type DeleteTaskInput struct { - TaskID string `json:"taskID"` + TaskID uuid.UUID `json:"taskID"` } type DeleteTaskPayload struct { - TaskID string `json:"taskID"` + TaskID uuid.UUID `json:"taskID"` } type DeleteTeam struct { @@ -184,11 +184,11 @@ type FindTeam struct { } type FindUser struct { - UserID string `json:"userId"` + UserID uuid.UUID `json:"userID"` } type LogoutUser struct { - UserID string `json:"userID"` + UserID uuid.UUID `json:"userID"` } type MePayload struct { @@ -225,19 +225,19 @@ type NewProjectLabel struct { } type NewRefreshToken struct { - UserID string `json:"userId"` + UserID uuid.UUID `json:"userID"` } type NewTask struct { - TaskGroupID string `json:"taskGroupID"` - Name string `json:"name"` - Position float64 `json:"position"` + TaskGroupID uuid.UUID `json:"taskGroupID"` + Name string `json:"name"` + Position float64 `json:"position"` } type NewTaskGroup struct { - ProjectID string `json:"projectID"` - Name string `json:"name"` - Position float64 `json:"position"` + ProjectID uuid.UUID `json:"projectID"` + Name string `json:"name"` + Position float64 `json:"position"` } type NewTaskGroupLocation struct { @@ -303,6 +303,7 @@ type ProjectsFilter struct { } type RemoveTaskLabelInput struct { + TaskID uuid.UUID `json:"taskID"` TaskLabelID uuid.UUID `json:"taskLabelID"` } @@ -388,13 +389,13 @@ type UpdateProjectName struct { } type UpdateTaskChecklistItemLocation struct { - ChecklistID uuid.UUID `json:"checklistID"` - ChecklistItemID uuid.UUID `json:"checklistItemID"` - Position float64 `json:"position"` + TaskChecklistID uuid.UUID `json:"taskChecklistID"` + TaskChecklistItemID uuid.UUID `json:"taskChecklistItemID"` + Position float64 `json:"position"` } type UpdateTaskChecklistItemLocationPayload struct { - ChecklistID uuid.UUID `json:"checklistID"` + TaskChecklistID uuid.UUID `json:"taskChecklistID"` PrevChecklistID uuid.UUID `json:"prevChecklistID"` ChecklistItem *db.TaskChecklistItem `json:"checklistItem"` } @@ -405,8 +406,8 @@ type UpdateTaskChecklistItemName struct { } type UpdateTaskChecklistLocation struct { - ChecklistID uuid.UUID `json:"checklistID"` - Position float64 `json:"position"` + TaskChecklistID uuid.UUID `json:"taskChecklistID"` + Position float64 `json:"position"` } type UpdateTaskChecklistLocationPayload struct { @@ -439,8 +440,8 @@ type UpdateTaskLocationPayload struct { } type UpdateTaskName struct { - TaskID string `json:"taskID"` - Name string `json:"name"` + TaskID uuid.UUID `json:"taskID"` + Name string `json:"name"` } type UpdateTeamMemberRole struct { @@ -648,10 +649,13 @@ func (e EntityType) MarshalGQL(w io.Writer) { type ObjectType string const ( - ObjectTypeOrg ObjectType = "ORG" - ObjectTypeTeam ObjectType = "TEAM" - ObjectTypeProject ObjectType = "PROJECT" - ObjectTypeTask ObjectType = "TASK" + ObjectTypeOrg ObjectType = "ORG" + ObjectTypeTeam ObjectType = "TEAM" + ObjectTypeProject ObjectType = "PROJECT" + ObjectTypeTask ObjectType = "TASK" + ObjectTypeTaskGroup ObjectType = "TASK_GROUP" + ObjectTypeTaskChecklist ObjectType = "TASK_CHECKLIST" + ObjectTypeTaskChecklistItem ObjectType = "TASK_CHECKLIST_ITEM" ) var AllObjectType = []ObjectType{ @@ -659,11 +663,14 @@ var AllObjectType = []ObjectType{ ObjectTypeTeam, ObjectTypeProject, ObjectTypeTask, + ObjectTypeTaskGroup, + ObjectTypeTaskChecklist, + ObjectTypeTaskChecklistItem, } func (e ObjectType) IsValid() bool { switch e { - case ObjectTypeOrg, ObjectTypeTeam, ObjectTypeProject, ObjectTypeTask: + case ObjectTypeOrg, ObjectTypeTeam, ObjectTypeProject, ObjectTypeTask, ObjectTypeTaskGroup, ObjectTypeTaskChecklist, ObjectTypeTaskChecklistItem: return true } return false diff --git a/internal/graph/schema.graphqls b/internal/graph/schema.graphqls index 7e2571f..1fb7c12 100644 --- a/internal/graph/schema.graphqls +++ b/internal/graph/schema.graphqls @@ -174,6 +174,9 @@ enum ObjectType { TEAM PROJECT TASK + TASK_GROUP + TASK_CHECKLIST + TASK_CHECKLIST_ITEM } directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!) on FIELD_DEFINITION @@ -215,7 +218,7 @@ input ProjectsFilter { } input FindUser { - userId: String! + userID: UUID! } input FindProject { @@ -297,15 +300,15 @@ type DeleteProjectPayload { extend type Mutation { createProjectLabel(input: NewProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) deleteProjectLabel(input: DeleteProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabel(input: UpdateProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelName(input: UpdateProjectLabelName!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelColor(input: UpdateProjectLabelColor!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) } input NewProjectLabel { @@ -377,29 +380,29 @@ type UpdateProjectMemberRolePayload { extend type Mutation { createTask(input: NewTask!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTask(input: DeleteTaskInput!): - DeleteTaskPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDescription(input: UpdateTaskDescriptionInput!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskLocation(input: NewTaskLocation!): - UpdateTaskLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskName(input: UpdateTaskName!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) setTaskComplete(input: SetTaskComplete!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDueDate(input: UpdateTaskDueDate!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) assignTask(input: AssignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) unassignTask(input: UnassignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) } input NewTask { - taskGroupID: String! + taskGroupID: UUID! name: String! position: Float! } @@ -441,54 +444,55 @@ input NewTaskLocation { } input DeleteTaskInput { - taskID: String! + taskID: UUID! } type DeleteTaskPayload { - taskID: String! + taskID: UUID! } input UpdateTaskName { - taskID: String! + taskID: UUID! name: String! } extend type Mutation { createTaskChecklist(input: CreateTaskChecklist!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) deleteTaskChecklist(input: DeleteTaskChecklist!): - DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistName(input: UpdateTaskChecklistName!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) createTaskChecklistItem(input: CreateTaskChecklistItem!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): - DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!): - UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) + + updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): + DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!): - UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) } input UpdateTaskChecklistItemLocation { - checklistID: UUID! - checklistItemID: UUID! + taskChecklistID: UUID! + taskChecklistItemID: UUID! position: Float! } type UpdateTaskChecklistItemLocationPayload { - checklistID: UUID! + taskChecklistID: UUID! prevChecklistID: UUID! checklistItem: TaskChecklistItem! } input UpdateTaskChecklistLocation { - checklistID: UUID! + taskChecklistID: UUID! position: Float! } @@ -541,19 +545,19 @@ type DeleteTaskChecklistPayload { extend type Mutation { createTaskGroup(input: NewTaskGroup!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateTaskGroupLocation(input: NewTaskGroupLocation!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) updateTaskGroupName(input: UpdateTaskGroupName!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroup(input: DeleteTaskGroupInput!): - DeleteTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) duplicateTaskGroup(input: DuplicateTaskGroup!): - DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) sortTaskGroup(input: SortTaskGroup!): - SortTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + SortTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroupTasks(input: DeleteTaskGroupTasks!): - DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) } input DeleteTaskGroupTasks { @@ -612,19 +616,31 @@ type DeleteTaskGroupPayload { } input NewTaskGroup { - projectID: String! + projectID: UUID! name: String! position: Float! } +extend type Mutation { + addTaskLabel(input: AddTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + removeTaskLabel(input: RemoveTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + toggleTaskLabel(input: ToggleTaskLabelInput!): + ToggleTaskLabelPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + +} + input AddTaskLabelInput { taskID: UUID! projectLabelID: UUID! } input RemoveTaskLabelInput { + taskID: UUID! taskLabelID: UUID! } + input ToggleTaskLabelInput { taskID: UUID! projectLabelID: UUID! @@ -634,15 +650,6 @@ type ToggleTaskLabelPayload { active: Boolean! task: Task! } -extend type Mutation { - addTaskLabel(input: AddTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - removeTaskLabel(input: RemoveTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - toggleTaskLabel(input: ToggleTaskLabelInput!): - ToggleTaskLabelPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - -} extend type Mutation { deleteTeam(input: DeleteTeam!): @@ -758,7 +765,7 @@ type UpdateUserRolePayload { } input NewRefreshToken { - userId: String! + userID: UUID! } input NewUserAccount { @@ -771,7 +778,7 @@ input NewUserAccount { } input LogoutUser { - userID: String! + userID: UUID! } input DeleteUserAccount { diff --git a/internal/graph/schema.resolvers.go b/internal/graph/schema.resolvers.go index 35f3638..be1b33e 100644 --- a/internal/graph/schema.resolvers.go +++ b/internal/graph/schema.resolvers.go @@ -179,14 +179,9 @@ func (r *mutationResolver) UpdateProjectMemberRole(ctx context.Context, input Up } func (r *mutationResolver) CreateTask(ctx context.Context, input NewTask) (*db.Task, error) { - taskGroupID, err := uuid.Parse(input.TaskGroupID) - if err != nil { - log.WithError(err).Error("issue while parsing task group ID") - return &db.Task{}, err - } createdAt := time.Now().UTC() - log.WithFields(log.Fields{"positon": input.Position, "taskGroupID": taskGroupID}).Info("creating task") - task, err := r.Repository.CreateTask(ctx, db.CreateTaskParams{taskGroupID, createdAt, input.Name, input.Position}) + log.WithFields(log.Fields{"positon": input.Position, "taskGroupID": input.TaskGroupID}).Info("creating task") + task, err := r.Repository.CreateTask(ctx, db.CreateTaskParams{input.TaskGroupID, createdAt, input.Name, input.Position}) if err != nil { log.WithError(err).Error("issue while creating task") return &db.Task{}, err @@ -195,19 +190,14 @@ func (r *mutationResolver) CreateTask(ctx context.Context, input NewTask) (*db.T } func (r *mutationResolver) DeleteTask(ctx context.Context, input DeleteTaskInput) (*DeleteTaskPayload, error) { - taskID, err := uuid.Parse(input.TaskID) - if err != nil { - return &DeleteTaskPayload{}, err - } - log.WithFields(log.Fields{ - "taskID": taskID.String(), + "taskID": input.TaskID, }).Info("deleting task") - err = r.Repository.DeleteTaskByID(ctx, taskID) + err := r.Repository.DeleteTaskByID(ctx, input.TaskID) if err != nil { return &DeleteTaskPayload{}, err } - return &DeleteTaskPayload{taskID.String()}, nil + return &DeleteTaskPayload{input.TaskID}, nil } func (r *mutationResolver) UpdateTaskDescription(ctx context.Context, input UpdateTaskDescriptionInput) (*db.Task, error) { @@ -226,11 +216,7 @@ func (r *mutationResolver) UpdateTaskLocation(ctx context.Context, input NewTask } func (r *mutationResolver) UpdateTaskName(ctx context.Context, input UpdateTaskName) (*db.Task, error) { - taskID, err := uuid.Parse(input.TaskID) - if err != nil { - return &db.Task{}, err - } - task, err := r.Repository.UpdateTaskName(ctx, db.UpdateTaskNameParams{taskID, input.Name}) + task, err := r.Repository.UpdateTaskName(ctx, db.UpdateTaskNameParams{input.TaskID, input.Name}) return &task, err } @@ -336,6 +322,16 @@ func (r *mutationResolver) CreateTaskChecklistItem(ctx context.Context, input Cr return &taskChecklistItem, nil } +func (r *mutationResolver) UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) { + checklist, err := r.Repository.UpdateTaskChecklistPosition(ctx, db.UpdateTaskChecklistPositionParams{Position: input.Position, TaskChecklistID: input.TaskChecklistID}) + + if err != nil { + return &UpdateTaskChecklistLocationPayload{}, err + } + + return &UpdateTaskChecklistLocationPayload{Checklist: &checklist}, nil +} + func (r *mutationResolver) UpdateTaskChecklistItemName(ctx context.Context, input UpdateTaskChecklistItemName) (*db.TaskChecklistItem, error) { task, err := r.Repository.UpdateTaskChecklistItemName(ctx, db.UpdateTaskChecklistItemNameParams{TaskChecklistItemID: input.TaskChecklistItemID, Name: input.Name, @@ -375,34 +371,20 @@ func (r *mutationResolver) DeleteTaskChecklistItem(ctx context.Context, input De }, err } -func (r *mutationResolver) UpdateTaskChecklistLocation(ctx context.Context, input UpdateTaskChecklistLocation) (*UpdateTaskChecklistLocationPayload, error) { - checklist, err := r.Repository.UpdateTaskChecklistPosition(ctx, db.UpdateTaskChecklistPositionParams{Position: input.Position, TaskChecklistID: input.ChecklistID}) - - if err != nil { - return &UpdateTaskChecklistLocationPayload{}, err - } - - return &UpdateTaskChecklistLocationPayload{Checklist: &checklist}, nil -} - func (r *mutationResolver) UpdateTaskChecklistItemLocation(ctx context.Context, input UpdateTaskChecklistItemLocation) (*UpdateTaskChecklistItemLocationPayload, error) { - currentChecklistItem, err := r.Repository.GetTaskChecklistItemByID(ctx, input.ChecklistItemID) + currentChecklistItem, err := r.Repository.GetTaskChecklistItemByID(ctx, input.TaskChecklistItemID) - checklistItem, err := r.Repository.UpdateTaskChecklistItemLocation(ctx, db.UpdateTaskChecklistItemLocationParams{TaskChecklistID: input.ChecklistID, TaskChecklistItemID: input.ChecklistItemID, Position: input.Position}) + checklistItem, err := r.Repository.UpdateTaskChecklistItemLocation(ctx, db.UpdateTaskChecklistItemLocationParams{TaskChecklistID: input.TaskChecklistID, TaskChecklistItemID: input.TaskChecklistItemID, Position: input.Position}) if err != nil { return &UpdateTaskChecklistItemLocationPayload{}, err } - return &UpdateTaskChecklistItemLocationPayload{PrevChecklistID: currentChecklistItem.TaskChecklistID, ChecklistID: input.ChecklistID, ChecklistItem: &checklistItem}, err + return &UpdateTaskChecklistItemLocationPayload{PrevChecklistID: currentChecklistItem.TaskChecklistID, TaskChecklistID: input.TaskChecklistID, ChecklistItem: &checklistItem}, err } func (r *mutationResolver) CreateTaskGroup(ctx context.Context, input NewTaskGroup) (*db.TaskGroup, error) { createdAt := time.Now().UTC() - projectID, err := uuid.Parse(input.ProjectID) - if err != nil { - return &db.TaskGroup{}, err - } project, err := r.Repository.CreateTaskGroup(ctx, - db.CreateTaskGroupParams{projectID, createdAt, input.Name, input.Position}) + db.CreateTaskGroupParams{input.ProjectID, createdAt, input.Name, input.Position}) return &project, err } @@ -773,12 +755,7 @@ func (r *mutationResolver) DeleteUserAccount(ctx context.Context, input DeleteUs } func (r *mutationResolver) LogoutUser(ctx context.Context, input LogoutUser) (bool, error) { - userID, err := uuid.Parse(input.UserID) - if err != nil { - return false, err - } - - err = r.Repository.DeleteRefreshTokenByUserID(ctx, userID) + err := r.Repository.DeleteRefreshTokenByUserID(ctx, input.UserID) return true, err } @@ -978,11 +955,7 @@ func (r *queryResolver) Users(ctx context.Context) ([]db.UserAccount, error) { } func (r *queryResolver) FindUser(ctx context.Context, input FindUser) (*db.UserAccount, error) { - userID, err := uuid.Parse(input.UserID) - if err != nil { - return &db.UserAccount{}, err - } - account, err := r.Repository.GetUserAccountByID(ctx, userID) + account, err := r.Repository.GetUserAccountByID(ctx, input.UserID) if err == sql.ErrNoRows { return &db.UserAccount{}, &gqlerror.Error{ Message: "User not found", diff --git a/internal/graph/schema/_root.gql b/internal/graph/schema/_root.gql index 3667cfb..a45a29b 100644 --- a/internal/graph/schema/_root.gql +++ b/internal/graph/schema/_root.gql @@ -14,6 +14,9 @@ enum ObjectType { TEAM PROJECT TASK + TASK_GROUP + TASK_CHECKLIST + TASK_CHECKLIST_ITEM } directive @hasRole(roles: [RoleLevel!]!, level: ActionLevel!, type: ObjectType!) on FIELD_DEFINITION @@ -55,7 +58,7 @@ input ProjectsFilter { } input FindUser { - userId: String! + userID: UUID! } input FindProject { diff --git a/internal/graph/schema/project_label.gql b/internal/graph/schema/project_label.gql index 863f56e..8089161 100644 --- a/internal/graph/schema/project_label.gql +++ b/internal/graph/schema/project_label.gql @@ -1,14 +1,14 @@ extend type Mutation { createProjectLabel(input: NewProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) deleteProjectLabel(input: DeleteProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabel(input: UpdateProjectLabel!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelName(input: UpdateProjectLabelName!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateProjectLabelColor(input: UpdateProjectLabelColor!): - ProjectLabel! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + ProjectLabel! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) } input NewProjectLabel { diff --git a/internal/graph/schema/task.gql b/internal/graph/schema/task.gql index 0f63b8b..3403868 100644 --- a/internal/graph/schema/task.gql +++ b/internal/graph/schema/task.gql @@ -1,28 +1,28 @@ extend type Mutation { createTask(input: NewTask!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTask(input: DeleteTaskInput!): - DeleteTaskPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDescription(input: UpdateTaskDescriptionInput!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskLocation(input: NewTaskLocation!): - UpdateTaskLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskName(input: UpdateTaskName!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) setTaskComplete(input: SetTaskComplete!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) updateTaskDueDate(input: UpdateTaskDueDate!): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) assignTask(input: AssignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) unassignTask(input: UnassignTaskInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: TASK) + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) } input NewTask { - taskGroupID: String! + taskGroupID: UUID! name: String! position: Float! } @@ -64,14 +64,14 @@ input NewTaskLocation { } input DeleteTaskInput { - taskID: String! + taskID: UUID! } type DeleteTaskPayload { - taskID: String! + taskID: UUID! } input UpdateTaskName { - taskID: String! + taskID: UUID! name: String! } diff --git a/internal/graph/schema/task_checklist.gql b/internal/graph/schema/task_checklist.gql index 70af81e..6b20575 100644 --- a/internal/graph/schema/task_checklist.gql +++ b/internal/graph/schema/task_checklist.gql @@ -1,39 +1,40 @@ extend type Mutation { createTaskChecklist(input: CreateTaskChecklist!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) deleteTaskChecklist(input: DeleteTaskChecklist!): - DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskChecklistPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistName(input: UpdateTaskChecklistName!): - TaskChecklist! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklist! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) createTaskChecklistItem(input: CreateTaskChecklistItem!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): - TaskChecklistItem! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): - DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) updateTaskChecklistLocation(input: UpdateTaskChecklistLocation!): - UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST) + + updateTaskChecklistItemName(input: UpdateTaskChecklistItemName!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + setTaskChecklistItemComplete(input: SetTaskChecklistItemComplete!): + TaskChecklistItem! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) + deleteTaskChecklistItem(input: DeleteTaskChecklistItem!): + DeleteTaskChecklistItemPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) updateTaskChecklistItemLocation(input: UpdateTaskChecklistItemLocation!): - UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + UpdateTaskChecklistItemLocationPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_CHECKLIST_ITEM) } input UpdateTaskChecklistItemLocation { - checklistID: UUID! - checklistItemID: UUID! + taskChecklistID: UUID! + taskChecklistItemID: UUID! position: Float! } type UpdateTaskChecklistItemLocationPayload { - checklistID: UUID! + taskChecklistID: UUID! prevChecklistID: UUID! checklistItem: TaskChecklistItem! } input UpdateTaskChecklistLocation { - checklistID: UUID! + taskChecklistID: UUID! position: Float! } diff --git a/internal/graph/schema/task_group.gql b/internal/graph/schema/task_group.gql index 0ed8cb6..ba40088 100644 --- a/internal/graph/schema/task_group.gql +++ b/internal/graph/schema/task_group.gql @@ -1,18 +1,18 @@ extend type Mutation { createTaskGroup(input: NewTaskGroup!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: PROJECT) updateTaskGroupLocation(input: NewTaskGroupLocation!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) updateTaskGroupName(input: UpdateTaskGroupName!): - TaskGroup! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + TaskGroup! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroup(input: DeleteTaskGroupInput!): - DeleteTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) duplicateTaskGroup(input: DuplicateTaskGroup!): - DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DuplicateTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) sortTaskGroup(input: SortTaskGroup!): - SortTaskGroupPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + SortTaskGroupPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) deleteTaskGroupTasks(input: DeleteTaskGroupTasks!): - DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) + DeleteTaskGroupTasksPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK_GROUP) } input DeleteTaskGroupTasks { @@ -71,7 +71,7 @@ type DeleteTaskGroupPayload { } input NewTaskGroup { - projectID: String! + projectID: UUID! name: String! position: Float! } diff --git a/internal/graph/schema/task_label.gql b/internal/graph/schema/task_label.gql index ef2886d..85e9388 100644 --- a/internal/graph/schema/task_label.gql +++ b/internal/graph/schema/task_label.gql @@ -1,11 +1,23 @@ +extend type Mutation { + addTaskLabel(input: AddTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + removeTaskLabel(input: RemoveTaskLabelInput): + Task! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + toggleTaskLabel(input: ToggleTaskLabelInput!): + ToggleTaskLabelPayload! @hasRole(roles: [ADMIN, MEMBER], level: PROJECT, type: TASK) + +} + input AddTaskLabelInput { taskID: UUID! projectLabelID: UUID! } input RemoveTaskLabelInput { + taskID: UUID! taskLabelID: UUID! } + input ToggleTaskLabelInput { taskID: UUID! projectLabelID: UUID! @@ -15,12 +27,3 @@ type ToggleTaskLabelPayload { active: Boolean! task: Task! } -extend type Mutation { - addTaskLabel(input: AddTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - removeTaskLabel(input: RemoveTaskLabelInput): - Task! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - toggleTaskLabel(input: ToggleTaskLabelInput!): - ToggleTaskLabelPayload! @hasRole(roles: [ADMIN], level: PROJECT, type: PROJECT) - -} diff --git a/internal/graph/schema/user.gql b/internal/graph/schema/user.gql index 6713657..6f85792 100644 --- a/internal/graph/schema/user.gql +++ b/internal/graph/schema/user.gql @@ -46,7 +46,7 @@ type UpdateUserRolePayload { } input NewRefreshToken { - userId: String! + userID: UUID! } input NewUserAccount { @@ -59,7 +59,7 @@ input NewUserAccount { } input LogoutUser { - userID: String! + userID: UUID! } input DeleteUserAccount { diff --git a/scripts/lint.sh b/scripts/lint.sh index e22d3f1..e720a2d 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,2 +1,14 @@ -#!/bin/bash -yarn --cwd frontend eslint $(echo $1 | sed 's/frontend\///g') +#!/bin/sh + +PASS=true +for FILE in "$@" +do + yarn --cwd frontend run eslint $(echo $FILE | sed 's/frontend\///g') + if [ "$?" -eq 1 ]; then + PASS=false + fi +done + +if [ "$PASS" = "false" ]; then + exit 1 +fi