What is the purpose of @aws_subscribe annotation?

Viewed 1104

I am reading realtime data documentation but do not understandwhat is the purpose of @aws_subscribe. Could somebody explain this in simple English? Examples about how subscriptions works with/without annotation will help a lot.

1 Answers

Using the @aws_subscribe directive, you can declare the mutations a subscription is subscribed to. For example:

type Mutation {
  createPost(): Post
  editPost(): Post
  deletePost(): Post
}

type  Subscription {
  updatedPost(): Post
    @aws_subscribe(mutations: ["createPost","editPost","deletePost"])
}
Related