-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b233ae
commit 4051401
Showing
15 changed files
with
195 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
const notiDefs = gql` | ||
extend type Query { | ||
allNotis: [Notification]! | ||
userNotis(data: UserNotiInfoInput!): [Notification]! | ||
} | ||
input UserNotiInfoInput { | ||
userId: ID! | ||
} | ||
# _______________________________________________________ | ||
# _______________________________________________________ | ||
extend type Mutation { | ||
deleteNoti(data: DeleteNotiInput!): Notification! | ||
deleteAllNoti: DeleteAllReturnType! | ||
} | ||
input DeleteNotiInput { | ||
notiId: ID! | ||
} | ||
type Notification { | ||
id: ID! | ||
type: String! | ||
postId: String! | ||
userTriggerId: User! | ||
userIds: [User]! | ||
createdAt: String! | ||
} | ||
`; | ||
|
||
export default notiDefs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { prisma } from '../../prisma/database.js'; | ||
|
||
const notiMutation = { | ||
deleteNoti: async (parent, args, info) => { | ||
let notification; | ||
try { | ||
notification = await prisma.notification.delete({ | ||
where: { | ||
id: args.data.notiId, | ||
}, | ||
}); | ||
} catch (e) { | ||
console.log(e); | ||
throw e; | ||
} | ||
|
||
return notification; | ||
}, | ||
deleteAllNoti: async (parent, args, info) => { | ||
let result; | ||
try { | ||
result = await prisma.notification.deleteMany({}); | ||
} catch (e) { | ||
console.log(e); | ||
throw e; | ||
} | ||
|
||
return result; | ||
}, | ||
}; | ||
|
||
export default notiMutation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { prisma } from '../../prisma/database.js'; | ||
|
||
const notiQuery = { | ||
allNotis: async (parent, args, info) => { | ||
return await prisma.notification.findMany(); | ||
}, | ||
userNotis: async (parent, args, info) => { | ||
return await prisma.notification.findMany({ | ||
where: { | ||
userIds: { has: args.data.userId }, | ||
}, | ||
orderBy: [ | ||
{ | ||
createdAt: 'desc', | ||
}, | ||
// { isRead: 'desc' }, | ||
], | ||
}); | ||
}, | ||
}; | ||
|
||
export default notiQuery; |
Oops, something went wrong.