mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Update resolver for paginated notifications
This commit is contained in:
parent
4448c12f2e
commit
f34c8f44e0
@ -18,9 +18,8 @@ export default {
|
||||
notifications: async (_parent, args, context, _resolveInfo) => {
|
||||
const { user: currentUser } = context
|
||||
const session = context.driver.session()
|
||||
let notifications
|
||||
let whereClause
|
||||
let orderByClause
|
||||
let notifications, whereClause, orderByClause
|
||||
|
||||
switch (args.read) {
|
||||
case true:
|
||||
whereClause = 'WHERE notification.read = TRUE'
|
||||
@ -41,13 +40,15 @@ export default {
|
||||
default:
|
||||
orderByClause = ''
|
||||
}
|
||||
|
||||
const offset = args.offset ? `SKIP ${args.offset}` : ''
|
||||
const limit = args.first ? `LIMIT ${args.first}` : ''
|
||||
try {
|
||||
const cypher = `
|
||||
MATCH (resource {deleted: false, disabled: false})-[notification:NOTIFIED]->(user:User {id:$id})
|
||||
${whereClause}
|
||||
RETURN resource, notification, user
|
||||
${orderByClause}
|
||||
${offset} ${limit}
|
||||
`
|
||||
const result = await session.run(cypher, { id: currentUser.id })
|
||||
notifications = await result.records.map(transformReturnType)
|
||||
|
||||
@ -23,7 +23,7 @@ enum NotificationReason {
|
||||
}
|
||||
|
||||
type Query {
|
||||
notifications(read: Boolean, orderBy: NotificationOrdering): [NOTIFIED]
|
||||
notifications(read: Boolean, orderBy: NotificationOrdering, first: Int, offset: Int): [NOTIFIED]
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user