amplify-flutter
amplify-flutter copied to clipboard
feat(api): .subscribe() for GraphQL
WIP: This is a rough early draft of subscriptions for GraphQL in dart. It implements the appsync real-time client described on https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-data.html. It still needs tests, error handling, comments, cleanup, etc...
Just trying to solicit some early feedback on the approach before adding that stuff.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Codecov Report
Merging #1915 (6e384c3) into feat/api-next (3ac59f4) will increase coverage by
0.22%. The diff coverage is71.92%.
@@ Coverage Diff @@
## feat/api-next #1915 +/- ##
=================================================
+ Coverage 44.82% 45.05% +0.22%
=================================================
Files 129 129
Lines 7752 7853 +101
=================================================
+ Hits 3475 3538 +63
- Misses 4277 4315 +38
| Flag | Coverage Δ | |
|---|---|---|
| android-unit-tests | ∅ <ø> (∅) |
|
| flutter-unit-tests | 30.00% <71.92%> (+1.50%) |
:arrow_up: |
| ios-unit-tests | 89.48% <ø> (+0.39%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...kages/api/amplify_api/lib/src/api_plugin_impl.dart | 81.73% <30.00%> (-5.51%) |
:arrow_down: |
| ..._api/lib/src/graphql/ws/web_socket_connection.dart | 59.77% <59.77%> (ø) |
|
| ...plify_api/lib/src/graphql/ws/web_socket_types.dart | 79.36% <79.36%> (ø) |
|
| ...phql/ws/web_socket_message_stream_transformer.dart | 90.47% <90.47%> (ø) |
|
| ..._api/lib/src/decorators/web_socket_auth_utils.dart | 100.00% <100.00%> (ø) |
|
| .../ios/unit_tests/amplify_flutter_exampleTests.swift | ||
| ...plify_flutter/example/ios/Runner/AppDelegate.swift | ||
| ...ter/example/ios/unit_tests/AtomicResultTests.swift | ||
| ...e/ios/unit_tests/MockAnalyticsCategoryPlugin.swift |
I'm still working on this, especially testing, logging, error handling, many comments not addressed. However, I did refactor the auth logic to use more pure functions and added lots of comments there. Let me know if still difficult to follow.
Nice work!
Question: Does the example app need to be updated to reflect any api changes?
No API changes for subscriptions, though I did just make a change to example app with last rev so unsubscribe button works.