-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): .subscribe() for GraphQL #1915
feat(api): .subscribe() for GraphQL #1915
Conversation
* feat(api): GraphQL API key auth mode * BREAKING CHANGE: GraphQL response errors now nullable
…r registers in Auth (#1851)
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/api/amplify_api/lib/src/graphql/ws/websocket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/decorators/authorize_websocket_message.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/decorators/authorize_websocket_message.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_message.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_message_stream_transformer.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_message_stream_transformer.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/websocket_message.dart
Outdated
Show resolved
Hide resolved
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
Question: Does the example app need to be updated to reflect any api changes?
packages/api/amplify_api/lib/src/graphql/ws/web_socket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_connection.dart
Outdated
Show resolved
Hide resolved
No API changes for subscriptions, though I did just make a change to example app with last rev so unsubscribe button works. |
* feat(api): GraphQL API key auth mode * BREAKING CHANGE: GraphQL response errors now nullable
…r registers in Auth (#1851)
c8297a6
to
64a50f6
Compare
@@ -12,10 +12,12 @@ | |||
// See the License for the specific language governing permissions and | |||
// limitations under the License. | |||
|
|||
import 'dart:async'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I never noticed this - but why are the other method channel tests/infra hanging around still? Outside of the configure API, we have no use for them anymore. These tests should just replace the old subscribe tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather do the cleanup in a single, separate PR. There was a task we mentioned in grooming for it.
packages/api/amplify_api/lib/src/graphql/ws/websocket_message_stream_transformer.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_connection.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work on the revisions. I noticed some things that will be nice for reconnection :)
packages/api/amplify_api/lib/src/decorators/web_socket_auth_utils.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/decorators/web_socket_auth_utils.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_connection.dart
Outdated
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_message_stream_transformer.dart
Show resolved
Hide resolved
packages/api/amplify_api/lib/src/graphql/ws/web_socket_types.dart
Outdated
Show resolved
Hide resolved
|
||
/// Extension of [WebSocketConnection] that stores messages internally instead | ||
/// of sending them. | ||
class MockWebSocketConnection extends WebSocketConnection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we should be mocking/injecting the WebSocketChannel
instead and not overriding methods since it becomes unclear what's being tested. Like here, I guess we're testing everything but connect
/send
- but those seem like good things to test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, I put a task in backlog to improve this
7300024
to
3ac59f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good for now. Once the method channel stuff is gone, I would recommend enabling lints at that point and doing the clean up for that so that future PRs meet spec. I've withheld all my formatting/style comments because it's easier if the analyzer prompts you as you go.
} | ||
|
||
/// Times out the connection (usually if a keep alive has not been received in time). | ||
void _timeout(Duration timeoutDuration) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this method do more, like close the WS connection? I guess Elijah's PR will address that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think there will be more cleanup here but will leave for Elijah.
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
Co-authored-by: Elijah Quartey <Equartey@users.noreply.github.com>
This PR has 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 does not implement reconnect on error or backoff/retry.
It does not include increased integration tests for other auth modes.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.