Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
HUNG-rushb committed Jan 7, 2024
1 parent 999be35 commit c298bbd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Type_Definitions/Noti_Noti.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ const notiDefs = gql`
extend type Mutation {
deleteNoti(data: DeleteNotiInput!): Notification!
deleteNotiUser(data: DeleteNotiUserInput!): Notification!
deleteAllNoti: DeleteAllReturnType!
}
input DeleteNotiInput {
notiId: ID!
}
input DeleteNotiUserInput {
userId: ID!
}
type Notification {
id: ID!
Expand Down
15 changes: 15 additions & 0 deletions src/resolvers/Mutation/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/Mutation/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c298bbd

Please sign in to comment.