https://github.com/sashee/appsync-subscriptions
Example code for AppSync Subscriptions
https://github.com/sashee/appsync-subscriptions
appsync aws graphql terraform
Last synced: 11 months ago
JSON representation
Example code for AppSync Subscriptions
- Host: GitHub
- URL: https://github.com/sashee/appsync-subscriptions
- Owner: sashee
- Created: 2022-01-17T10:23:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-10-22T14:41:51.000Z (over 3 years ago)
- Last Synced: 2025-01-29T14:09:50.132Z (about 1 year ago)
- Topics: appsync, aws, graphql, terraform
- Language: HCL
- Homepage: https://advancedweb.hu/real-time-data-with-appsync-subscriptions/
- Size: 9.77 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
```graphql
subscription MySubscription {
newTodo(name: "todo1") {
checked
created
name
id
}
}
```
On a separate tab, create a new Todo:
```graphql
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:
```graphql
mutation MyMutation {
addTodo(name: "todo5", userId: "user1") {
id
name
created
checked
}
}
```
No event this time.
### Advanced filtering
Subscribe to the other subscription field:
```graphql
subscription MySubscription {
todo(userId: "user1") {
todo {
checked
created
id
name
}
}
}
```
Create a Todo item:
```graphql
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```