Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are AppSync's subscriptions very limited to one specific use case?

Tags:

aws-appsync

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:

  • we can't filter out target to whom you want to send the data to

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.

  • it has to be linked to a specific mutation and it has to be of the same type

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.

  • It is not linked to a resolver

Can you please correct me If I'm wrong?

like image 366
Tom Avatar asked Feb 02 '18 11:02

Tom


1 Answers

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.

like image 82
widdy Avatar answered Oct 21 '22 18:10

widdy