From 98d12281df9ceac12395662a9f15128c6694696d Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Tue, 19 Jul 2022 21:50:05 +0200 Subject: [PATCH] Use graphql-loader --- .../components/notifications/NotificationItem.vue | 11 +---------- .../components/notifications/NotificationList.vue | 13 +------------ .../notifications/markNotificationRead.graphql | 8 ++++++++ .../notifications/myNotifications.graphql | 12 ++++++++++++ webpack.config.js | 5 +++++ 5 files changed, 27 insertions(+), 22 deletions(-) create mode 100644 aleksis/core/assets/components/notifications/markNotificationRead.graphql create mode 100644 aleksis/core/assets/components/notifications/myNotifications.graphql diff --git a/aleksis/core/assets/components/notifications/NotificationItem.vue b/aleksis/core/assets/components/notifications/NotificationItem.vue index dea29654a..6c05b112e 100644 --- a/aleksis/core/assets/components/notifications/NotificationItem.vue +++ b/aleksis/core/assets/components/notifications/NotificationItem.vue @@ -1,15 +1,6 @@ <template> <ApolloMutation - :mutation="gql => gql` - mutation ($id: ID!) { - markNotificationRead(id: $id) { - notification { - id - read - } - } - } - `" + :mutation="require('./markNotificationRead.graphql')" :variables="{ id: this.notification.id }" > <template v-slot="{ mutate, loading, error }"> diff --git a/aleksis/core/assets/components/notifications/NotificationList.vue b/aleksis/core/assets/components/notifications/NotificationList.vue index 815d66aef..8428fd711 100644 --- a/aleksis/core/assets/components/notifications/NotificationList.vue +++ b/aleksis/core/assets/components/notifications/NotificationList.vue @@ -1,17 +1,6 @@ <template> <ApolloQuery - :query="gql => gql`{ - myNotifications: whoAmI { - notifications { - id - title - description - link - created - sender - } - } - }`" + :query="require('./myNotifications.graphql')" :pollInterval="1000" > <template v-slot="{ result: { error, data }, isLoading }"> diff --git a/aleksis/core/assets/components/notifications/markNotificationRead.graphql b/aleksis/core/assets/components/notifications/markNotificationRead.graphql new file mode 100644 index 000000000..8cc7bed43 --- /dev/null +++ b/aleksis/core/assets/components/notifications/markNotificationRead.graphql @@ -0,0 +1,8 @@ +mutation ($id: ID!) { + markNotificationRead(id: $id) { + notification { + id + read + } + } +} diff --git a/aleksis/core/assets/components/notifications/myNotifications.graphql b/aleksis/core/assets/components/notifications/myNotifications.graphql new file mode 100644 index 000000000..efa51f2c8 --- /dev/null +++ b/aleksis/core/assets/components/notifications/myNotifications.graphql @@ -0,0 +1,12 @@ +{ + myNotifications: whoAmI { + notifications { + id + title + description + link + created + sender + } + } +} diff --git a/webpack.config.js b/webpack.config.js index d41985b0b..afdbda23a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -59,6 +59,11 @@ module.exports = { }, ], }, + { + test: /\.(graphql|gql)$/, + exclude: /node_modules/, + loader: 'graphql-tag/loader', + }, ], }, optimization: { -- GitLab