notification subscription

This commit is contained in:
Ulf Gebhardt 2023-07-20 13:41:59 +02:00
parent 9e52ec5469
commit 1b8b356432
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 5 additions and 10 deletions

View File

@ -7,8 +7,8 @@ export default {
notificationAdded: {
subscribe: withFilter(
() => pubsub.asyncIterator(NOTIFICATION_ADDED),
(payload, variables) => {
return payload.notificationAdded.to.id === variables.userId
(payload, variables, context) => {
return payload.notificationAdded.to.id === context.user?.id
},
),
},

View File

@ -38,5 +38,5 @@ type Mutation {
}
type Subscription {
notificationAdded(userId: ID!): NOTIFIED
notificationAdded: NOTIFIED
}

View File

@ -137,11 +137,6 @@ export default {
},
subscribeToMore: {
document: notificationAdded(),
variables() {
return {
userId: this.user.id,
}
},
updateQuery: (previousResult, { subscriptionData }) => {
const {
data: { notificationAdded: newNotification },

View File

@ -245,8 +245,8 @@ export const notificationAdded = () => {
${postFragment}
${groupFragment}
subscription notifications($userId: ID!) {
notificationAdded(userId: $userId) {
subscription notifications {
notificationAdded {
id
read
reason