Skip to content

Commit

Permalink
feat: finished implementations & started resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeessh committed Nov 4, 2023
1 parent af8b2af commit d8b7bc6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 4 additions & 5 deletions backend/typescript/graphql/resolvers/taskResolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
TaskDTO,
ITaskService,
} from '../../services/interfaces/taskService'
import {Prisma} from '@prisma/client'

const taskService : ITaskService = new TaskService();
const userService : IUserService = new UserService();
Expand All @@ -13,11 +14,9 @@ const taskResolvers = {
Query: {
task: async (
_parent: undefined,
{ id }: { id: string },
{ categoryId }: {categoryId: string},
{}
): Promise<TaskDTO> => {
return taskService.getTaskById(id);
{ id }: { id: string }
): Promise<Prisma.taskCreateInput> => {
return await taskService.getTaskById(id);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions backend/typescript/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ model user {
model task {
id Int @id @default(autoincrement())
category category? @relation(fields: [category_id], references: [id])
category_id Int @unique
category_id Int
title String
status Statuses
description String
assignee resident? @relation(fields: [assignee_id], references: [id])
assignee_id Int @unique
assignee_id Int
assigner staff? @relation(fields: [assigner_id], references: [id])
assigner_id Int @unique
assigner_id Int
credit_value Float
start_date DateTime
end_date DateTime?
Expand Down
18 changes: 15 additions & 3 deletions backend/typescript/services/implementations/taskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,21 @@ class TaskService implements ITaskService {
}
}

async deleteTaskById(taskId: string): Promise<TaskDTO>{
return {

async deleteTaskById(taskId: string): Promise<Prisma.taskCreateInput>{
try {
const task = await prisma.task.delete({
where: {
id: Number(taskId)
}
})

if (!task) {
throw new Error(`help`);
}

return task;
} catch (error: unknown) {
throw error;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion backend/typescript/services/interfaces/taskService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface ITaskService {
* @returns a TaskDTO with the deleted task's information
* @throws Error if task deletion fails
*/
deleteTaskById(taskId: string): Promise<TaskDTO>;
deleteTaskById(taskId: string): Promise<Prisma.taskCreateInput>;
}

export default ITaskService

0 comments on commit d8b7bc6

Please sign in to comment.