7

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?

Tom
  • 785
  • 10
  • 26
  • 2
    thanks much for the feedback! The service is still in preview and more features are being rolled out in the coming months related to the requirements you have above. Keep watching the AWS Mobile Blog for announcements. – Richard Feb 03 '18 at 22:57
  • 3
    Just to be clear: `I love AWS AppSync!` and I can't wait for this to be done to use it. I just wish all those features were there already :D – Tom Feb 04 '18 at 10:07
  • For fine-grained access controls on subscriptions, you can attach resolvers to your subscription fields and perform logic using the identity of the caller and AWS AppSync data sources. – Cris69 Apr 29 '19 at 03:53

1 Answers1

2

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.

widdy
  • 426
  • 5
  • 21