diff --git a/src/Type_Definitions/Noti_Noti.js b/src/Type_Definitions/Noti_Noti.js index fa94929..cf3e8c8 100644 --- a/src/Type_Definitions/Noti_Noti.js +++ b/src/Type_Definitions/Noti_Noti.js @@ -15,6 +15,7 @@ const notiDefs = gql` extend type Mutation { deleteNoti(data: DeleteNotiInput!): Notification! + deleteNotiUser(data: DeleteNotiUserInput!): Notification! deleteAllNoti: DeleteAllReturnType! } @@ -22,6 +23,10 @@ const notiDefs = gql` notiId: ID! } + input DeleteNotiUserInput { + userId: ID! + } + type Notification { id: ID! diff --git a/src/resolvers/Mutation/notification.js b/src/resolvers/Mutation/notification.js index eb5d94f..97e3970 100644 --- a/src/resolvers/Mutation/notification.js +++ b/src/resolvers/Mutation/notification.js @@ -16,6 +16,21 @@ const notiMutation = { return notification; }, + deleteNotiUser: async (parent, args, info) => { + let notification; + try { + notification = await prisma.notification.deleteMany({ + where: { + userIds: { has: args.data.userId }, + }, + }); + } catch (e) { + console.log(e); + throw e; + } + + return notification; + }, deleteAllNoti: async (parent, args, info) => { let result; try { diff --git a/src/resolvers/Mutation/post.js b/src/resolvers/Mutation/post.js index f3a84c8..4d9518a 100644 --- a/src/resolvers/Mutation/post.js +++ b/src/resolvers/Mutation/post.js @@ -51,7 +51,7 @@ const postMutation = { }); // console.log({ post }); - const a = await prisma.notification.create({ + await prisma.notification.create({ data: { type: 'POST_CREATED', postId: post.id,