Skip to content

sashee/appsync-subscriptions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example code for AppSync Subscriptions

Requirements

  • terraform
  • AWS account
  • AWS CLI configured

Deploy

  • terraform init
  • terraform apply

Use

Basic filtering

Go to the AWS Management Console and subscribe to new Todo items:

subscription MySubscription {
  newTodo(name: "todo1") {
    checked
    created
    name
    id
  }
}

On a separate tab, create a new Todo:

mutation MyMutation {
  addTodo(name: "todo1", userId: "user1") {
    id
    name
    created
    checked
  }
}

There is an event on the first tab. Try again with a different name:

mutation MyMutation {
  addTodo(name: "todo5", userId: "user1") {
    id
    name
    created
    checked
  }
}

No event this time.

Advanced filtering

Subscribe to the other subscription field:

subscription MySubscription {
  todo(userId: "user1") {
    todo {
      checked
      created
      id
      name
    }
  }
}

Create a Todo item:

mutation MyMutation {
  addTodo(name: "todo5", userId: "user1") {
    id
  }
}

There is an event. Notice that the Mutation has fewer fields than the Subscription.

Cleanup

  • terraform destroy

About

Example code for AppSync Subscriptions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages