I spend the last day trying AWS AppSync
I'm a bit disappointed with what subscriptions can do.
It seems to me that the current state of AppSync subscription
is for the use case where you have a list of items and you want it to be sync over all clients.
It's pretty limited compared to what apollo-subscription can do.
So if I understood the doc correctly:
I have use cases where mutations like a vote on a Post can lead to push data of a different Type to the owner of the Post only.
I have use cases where a mutation or even a query can lead to send a push to a specific target that is listening to the event.
Can you please correct me If I'm wrong?
As you already figured out, the result must be the same as from the mutation and you can't link your mutation to a resolver.
But concerning your first assumption:
It is possible to filter the results of a mutation. For example if you have the following mutation:
type Mutation {
addPost(input: PostAddInput!): Post!
}
input PostAddInput {
text: String!
author: ID!
}
You can publish the result of the mutation to the specific user with this subscription:
type Subscription {
addedPost(author_id: ID!): Post!
@aws_subscribe(mutations: ["addPost"])
}
Now you will only receive the results if the author_id of the mutation matches the subscribed author_id.
I also created an AppSync RDS repository on GitHub if you want to try it out by yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With