aws-amplify / aws-amplify/amplify-android
DataStore to establish Subscription with server-side filtering
- Dominant language
- Java
- Stars
- 287
- Forks
- 132
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 45
Description
DataStore translates the `syncExpression` over to the `filter` predicate on the GrapQL query. When DataStore performs a sync query, the filter is added, to perform server side filtering. When DataStore establishes the subscriptions, the filtering is applied on the client side.Since the subscription filtering feature released in April 2022, customers can provision AppSync with the `filter` input capability on their subscription operations. DataStore can now leverage this by passing in `filter` to the subscription request.
1. We attempt the subscription with the filter and catch ther error
2. Handle the specific "RTF" error as a retry without the filter for backwards compatibility.
References
https://github.com/aws-amplify/amplify-js/blob/main/packages/datastore/src/sync/processors/subscription.ts#L467-L492
https://github.com/aws-amplify/amplify-js/blob/main/packages/datastore/src/sync/processors/subscription.ts#L677-L682C10
This logic allows for backwards compatibility with AppSync backends without the subscription `filter` capability.
_Originally posted by @lawmicha in https://github.com/aws-amplify/amplify-swift/issues/3550#issuecomment-1984605196_
Contributor guide
Research direction
Start by reading the referenced amplify-js implementation in packages/datastore/src/sync/processors/subscription.ts, especially lines 467-492 and 677-682, then locate the corresponding DataStore subscription code in amplify-android. Done means subscriptions pass the syncExpression as a server-side filter and retry without it only for the specific RTF error, preserving compatibility with older AppSync backends.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, graphql, java
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100