aws-appsync-community
aws-appsync-community copied to clipboard
Invalidate multiple subscriptions in a mutation
I use $extensions.invalidateSubscriptions to close the subscription for users no longer allowed to receive updates and it works for a single subscription. But when I tried to invalidate multiple subscriptions, it seems that the last one overwrites the previous ones.
For example, users can subscribe to new files and documents:
type Subscription {
onFileChanged: File
@aws_subscribe(mutations: ["..."])
onDocumentChanged: Document
@aws_subscribe(mutations: ["..."])
}
Then I can delete the user:
type Mutation {
deleteUser(userId: ID!): ID!
}
What I want is to close the deleted user's subscription to both files and documents:
$extensions.invalidateSubscriptions({
"subscriptionField": "onFileChanged",
"payload": {
"userId": $ctx.args.userId
}
})
$extensions.invalidateSubscriptions({
"subscriptionField": "onDocumentChanged",
"payload": {
"userId": $ctx.args.userId
}
})
But this does not work. If only one of the $extensions.invalidateSubscriptions is present, then the subscription is closed. But when both, only the second is effective. I also could not find any hints that a single $extensions.invalidateSubscriptions can specify multiple subscriptionFields.
Is it something that is supported by AppSync and the problem is on my end, or a single mutation can only terminate connections to a single subscriptions?
Current behavior is that a single mutation can only terminate a single subscription. When you attempt to terminate more than one subscription in a single request it will only terminate the last subscription in the mutation. I've added work to enable termination of multiple subscriptions in a single request into our backlog.
Thank you, I'm looking forward to it!
Would also love this feature, where would I be able to track this backlog item?
Hi @billfine May I know how the state of terminating more than one subscription ? it will be useful for development., Thanks