diff --git a/backend/src/schema/resolvers/notifications.js b/backend/src/schema/resolvers/notifications.js index e46b61ba4..2db62e444 100644 --- a/backend/src/schema/resolvers/notifications.js +++ b/backend/src/schema/resolvers/notifications.js @@ -62,7 +62,7 @@ export default { let notification try { const cypher = ` - MATCH (resource {id: $resourceId})-[notification:NOTIFIED]->(user:User {id:$id}) + MATCH (resource {id: $resourceId})-[notification:NOTIFIED {read: FALSE}]->(user:User {id:$id}) SET notification.read = TRUE RETURN resource, notification, user ` diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index e11c9a73e..b321d449f 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -265,6 +265,20 @@ describe('given some notifications', () => { }, }) }) + + describe('but notification was already marked as read', () => { + beforeEach(async () => { + variables = { + ...variables, + id: 'p2', + } + }) + it('returns null', async () => { + const response = await mutate({ mutation: markAsReadMutation, variables }) + expect(response.data.markAsRead).toEqual(null) + expect(response.errors).toBeUndefined() + }) + }) }) describe('on a comment', () => {