From b417667d3184d8a04a45a33ff401f880ef61c551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Fri, 3 Apr 2020 15:25:07 +0200 Subject: [PATCH] Rename return property of 'extractNotificationDataOfCurrentUser' - Renamed 'report' to 'filedReport'. - Commented on the need of deep nested and similair properties for GQL of notifications. --- .../schema/resolvers/notifications.spec.js | 48 +++++++++++++++++++ .../components/Notification/Notification.vue | 8 ++-- .../NotificationsTable/NotificationsTable.vue | 9 ++-- webapp/components/utils/Notifications.js | 6 +-- webapp/graphql/User.js | 4 ++ 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/backend/src/schema/resolvers/notifications.spec.js b/backend/src/schema/resolvers/notifications.spec.js index 5be024074..6a2a2cff3 100644 --- a/backend/src/schema/resolvers/notifications.spec.js +++ b/backend/src/schema/resolvers/notifications.spec.js @@ -215,6 +215,8 @@ describe('given some notifications', () => { }) describe('notifications', () => { + // properties should be deep nested and the same as in the "markAsReadMutation" + // reason is to test if all deep nested data is collected correctly with the Cypher statement. if not there will be a GraphQL error const notificationQuery = gql` query($read: Boolean, $orderBy: NotificationOrdering) { notifications(read: $read, orderBy: $orderBy) { @@ -556,21 +558,67 @@ describe('given some notifications', () => { }) describe('markAsRead', () => { + // properties should be deep nested and the same as in the "notificationQuery" + // reason is to test if all deep nested data is collected correctly with the Cypher statement. if not there will be a GraphQL error const markAsReadMutation = gql` mutation($id: ID!) { markAsRead(id: $id) { createdAt + updatedAt read + reason from { __typename ... on Post { content + author { + id + } } ... on Comment { content + author { + id + } + post { + id + author { + id + } + } } ... on FiledReport { reportId + reasonCategory + reasonDescription + resource { + __typename + ... on User { + id + name + } + ... on Post { + id + title + content + author { + id + } + } + ... on Comment { + id + content + author { + id + } + post { + id + author { + id + } + } + } + } } } } diff --git a/webapp/components/Notification/Notification.vue b/webapp/components/Notification/Notification.vue index d53c13e1e..7d6902924 100644 --- a/webapp/components/Notification/Notification.vue +++ b/webapp/components/Notification/Notification.vue @@ -30,16 +30,16 @@
{{ $t(`notifications.report.category`) }}: - {{ $t('report.reason.category.options.' + notificationData.report.reasonCategory) }} + {{ $t('report.reason.category.options.' + notificationData.filedReport.reasonCategory) }}
{{ $t(`notifications.report.description`) }}: - {{ notificationData.report.reasonDescription }} + {{ notificationData.filedReport.reasonDescription }} — diff --git a/webapp/components/NotificationsTable/NotificationsTable.vue b/webapp/components/NotificationsTable/NotificationsTable.vue index f3424c84f..0f1591702 100644 --- a/webapp/components/NotificationsTable/NotificationsTable.vue +++ b/webapp/components/NotificationsTable/NotificationsTable.vue @@ -48,15 +48,18 @@ {{ $t(`notifications.report.category`) }}: - {{ $t('report.reason.category.options.' + scope.row.report.reasonCategory) }} + {{ $t('report.reason.category.options.' + scope.row.filedReport.reasonCategory) }}
{{ $t(`notifications.report.description`) }}: - {{ scope.row.report.reasonDescription }} + {{ scope.row.filedReport.reasonDescription }} — diff --git a/webapp/components/utils/Notifications.js b/webapp/components/utils/Notifications.js index 29eb0e390..4ba3f43ac 100644 --- a/webapp/components/utils/Notifications.js +++ b/webapp/components/utils/Notifications.js @@ -137,7 +137,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser) let post = null let comment = null let contentExcerpt = null - let report = null + let filedReport = null let isUser = false let isPost = false let isComment = false @@ -165,7 +165,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser) triggerer = post.author break case 'FiledReport': - report = { + filedReport = { reasonCategory: from.reasonCategory, reasonDescription: from.reasonDescription, } @@ -237,7 +237,7 @@ export const extractNotificationDataOfCurrentUser = (notification, currentUser) author, title, contentExcerpt, - report, + filedReport, reasonTranslationExtention, linkTo: { name: linkName, params: linkParams, ...linkHashParam }, } diff --git a/webapp/graphql/User.js b/webapp/graphql/User.js index 54e21510d..dbbec788c 100644 --- a/webapp/graphql/User.js +++ b/webapp/graphql/User.js @@ -61,6 +61,7 @@ export const minimisedUserQuery = () => { ` } +// properties have be in all notifications queries, mutations, and subscriptions here the same !!! export const notificationQuery = (i18n) => { return gql` ${userFragment} @@ -129,6 +130,7 @@ export const notificationQuery = (i18n) => { ` } +// properties have be in all notifications queries, mutations, and subscriptions here the same !!! export const markAsReadMutation = (i18n) => { return gql` ${userFragment} @@ -197,6 +199,7 @@ export const markAsReadMutation = (i18n) => { ` } +// properties have be in all notifications queries, mutations, and subscriptions here the same !!! export const notificationAdded = () => { return gql` ${userFragment} @@ -264,6 +267,7 @@ export const notificationAdded = () => { } ` } + export const followUserMutation = (i18n) => { return gql` ${userFragment}