aws / aws/aws-appsync-community
Feature Request: Custom Subscription datasource
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
I originally left this as a comment (https://github.com/aws/aws-appsync-community/issues/186#issuecomment-993239387) but I feel like it's more appropriate to start a new feature request.
Supporting custom datasources that trigger a subscription broadcast message would gives much more control than the current `@aws_subscribe` model.
I propose expanding the current directive of `@aws_subscribe(mutations: [...])` to take more inputs that represents a specific datasource, examples below:
1. **SQS Datasource**: `@aws_subscribe(sqs: [arn1, arn2, ...])`
2. **SNS Datasource**: `@aws_subscribe(sns: [arn1, arn2, ...])`
3. **Redis Datasource**: `@aws_subscribe(elasicache: [arn1, arn2, ...])`
4. **AWS IoT Core Datasource**: `@aws_subscribe(iot: [topic1, topic2, ...])`
Such that multiple datasources can be broadcasting to the same GraphQL subscription,
```graphql
type Subscription {
onUpdate: String! @aws_subscribe(
mutation: ["mutation1", "mutation2"]
sqs: [arn1, arn2, ...]
sns: [arn3, arn4, ...]
elasticache: [arn5, arn6, ...]
iot: [arn7, arn8, ...]
)
}
```
To accommodate event data shapes from different source, response resolver mapping templates can be utilized to morph the message body into the correct JSON that matches the expected return type of the corresponding subscription.
Contributor guide
Research direction
Start by reviewing the current @aws_subscribe directive and response resolver mapping templates, then compare the proposed SQS, SNS, ElastiCache, and IoT Core inputs with existing AppSync datasource behavior. Done would require an agreed design for multiple datasource inputs and the event-to-subscription data shape.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100