forked from aws-amplify/amplify-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): GraphQL Subscription Stream (aws-amplify#852)
* chore(datastore): Remove redundant files for the datastore example (aws-amplify#762) * feat(datastore): Populate belongs-to nested models (aws-amplify#658) * feat(datastore): Populate has-one and belongs-to nested models * Nest data under serializedData key and persist modelName * Resolve comment * Update packages/amplify_datastore/example/ios/unit_tests/resources/SchemaData.swift Co-authored-by: Chris F <[email protected]> * chore(amplify_api): add support for apiName to GraphQL requests (aws-amplify#553) * fix(amplify_api): prevent some fatal REST errors in Android Throw ApiException in android when PUT, POST, and PATCH REST requests have no body to prevent fatal error (aws-amplify#661). * chore(release): 0.2.2 (aws-amplify#781) * chore(release): missing dependency (aws-amplify#783) * Bump analytics version * Fix PR # * Bump all versions * Missing bump * Pin collections * chore: skip FlutterURLSessionTests (aws-amplify#795) * chore(lints): Add amplify_lints package (aws-amplify#808) * Add lints package * Add missing readme item * feat(auth): add options to resendSignUpCode (aws-amplify#738) * feat(auth): add options to resendSignUpCode * fix: add type export for sing up code options * chore: fix formatting issues * chore: update comments for consistency * chore: rename private method names for consistency * chore: update comments for consistency * chore: make ResendSignUpCodeOptions abstract * chore: update ResendSignUpCodeRequest serializeAsMap * chore: update ios test * chore update doc comments * chore: bump amplify-android to 1.24.0 * chore: remove star import * feat(auth): add support for options to resetPassword, confirmResetPassword (aws-amplify#743) * chore: rename confirmPassword to confirmResetPassword * chore: fix grammatical errors in docs * feat(auth): add options support for resetPassword, confirmResetPassword * chore: rename private methods for consistency * chore: update comments for consistency * chore: update ios tests * chore: fix comments * chore: handle deprecated methods * separate out deprecated class * chore: update serializeAsMap for consistency * chore: properly deprecate confirmPassword * chore: add deprecation annotation to interface * chore: bump amplify-android to 1.24.0 * chore: apply suggestions from code review * feat(auth): add options to updateAttribute, updateAttributes, resendUserAttributeConfirmationCode (aws-amplify#775) * chore: move attribute types to new dir * chore: rename fetch attribute classes * feat: add client metadata to user attribute methods * deprecate renamed types * chore: update comments for consistency * chore: rename methods, tests * chore: break out depracted classes, make new classes abstract * chore: revert star import * chore: bump amplify-android to 1.24.0 * chore: apply suggestions from code review * chore: remove empty line * Clean up pinpoint * Clean up pinpoint dart * Enable CI for analytics * Add iOS linting * Clean up * Update iOS script * Fix Android melos script * Update CI order * Add Dart lints to API * Apply Android/iOS lints to API * Add GraphQL subscription stream and tests * fix(amplify_datastore): ios send modelProviderVersion (aws-amplify#439) Co-authored-by: Hui Zhao <[email protected]> * feat(datastore): Add start and stop APIs (aws-amplify#811) * Convert file to LF mode * feat(datastore): Add start and stop APIs * Add docs * Resolve comments * chore(analytics): Apply lints (aws-amplify#810) * Clean up pinpoint * Clean up pinpoint dart * Enable CI for analytics * Add iOS linting * Clean up * Update iOS script * Fix Android melos script * Update CI order * Small changes * Update type * Add iOS whitespace rules * Update type * Apply updated rules * feat(auth): OIDC/Lambda Support (aws-amplify#777) * OIDC/Lambda support * Clean up * Fix iOS test * Add unit tests * Fix Android test * Fix Android tests * Refactor and remove AuthToken from the public API * Remove concurrent guards * Clean up * chore: upgrade amplify-android 1.24.1 (aws-amplify#829) * fix(datastore): return null for list field in nested model (aws-amplify#843) * fix(datastore): Better loggin on unhandled DataStoreHubEvent (aws-amplify#647) * fix(datastore): Better loggin on unhandled DataStoreHubEvent * Print unrecognized event details in iOS * Resolve comments * chore(api): Apply lints (aws-amplify#812) * Clean up pinpoint * Clean up pinpoint dart * Update iOS script * Update CI order * Add Dart lints to API * Apply Android/iOS lints to API * Rename uuid * Small changes * Fix scripts * Clean up * Fix unit tests * Continue impl * Fix android unit tests * Remove duplicate lint check * Fix analytics app * Adjust java options * Bump java RAM * Remove concurrency * Disable gradle daemon * Update gradle properties * Update gradle config * Revert "Update gradle config" This reverts commit a43ad29. * Revert gradle changes * Disable gradle daemon * Add kotlin style flags * Disable gradle daemon * Bump JVM memory * Change daemon setting * Adjust JVM memory * Lint debug only * Fix API tests * Bump deps and fix coverage script * Fix Gradle version * Revert unnecessary changes * Update melos postclean files * Enable fatal infos * Fix analyze scope * Fix postbootstrap * Fix missing sample app * Fix order in CI * Revert add sample app * Revert order change * Revert license date * Revert "Revert license date" This reverts commit 1b93b3f. * Clean up * Add multi-subscription w/ tests * Refactor tests * Fix native tests * Fix onEstablished * Fix docs * Add unknown exception tests * Clean up * Revert multi & add tests * Fix merge errors * Fix async dependency Co-authored-by: Hui Zhao <[email protected]> Co-authored-by: Chris F <[email protected]> Co-authored-by: José Sánchez <[email protected]> Co-authored-by: Travis Sheppard <[email protected]> Co-authored-by: Jordan Nelson <[email protected]> Co-authored-by: Kyle <[email protected]>
- Loading branch information
1 parent
d8f8485
commit f25b64e
Showing
21 changed files
with
721 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ class AmplifyAnalyticsBuilder { | |
return locationBuilder.build() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,4 +134,4 @@ object FlutterApiRequest { | |
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
packages/amplify_api/lib/graphql/graphql_subscription_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
import 'package:amplify_api/amplify_api.dart'; | ||
|
||
/// GraphQL subscription event types. | ||
enum GraphQLSubscriptionEventType { | ||
/// Triggered when data is received from a GraphQL subscription. | ||
data, | ||
|
||
/// Triggered when a GraphQL subscription completes either due to cancellation | ||
/// or a platform error. | ||
done, | ||
|
||
/// Triggered when a platform error occurs for a subscription. | ||
/// | ||
/// Currently only valid in Dart. | ||
error, | ||
} | ||
|
||
/// Helper functions for [GraphQLSubscriptionEventType]. | ||
extension GraphQLSubscriptionEventTypeX on GraphQLSubscriptionEventType { | ||
/// Converts a platform string to a [GraphQLSubscriptionEventType]. | ||
static GraphQLSubscriptionEventType fromString(String type) { | ||
switch (type) { | ||
case 'DATA': | ||
return GraphQLSubscriptionEventType.data; | ||
case 'DONE': | ||
return GraphQLSubscriptionEventType.done; | ||
default: | ||
throw UnsupportedError('Unsupported type: $type'); | ||
} | ||
} | ||
} | ||
|
||
/// {@template graphql_subscription_event} | ||
/// An event which occurs on a GraphQL subscription. | ||
/// {@endtemplate} | ||
class GraphQLSubscriptionEvent { | ||
/// The ID of the subscription. | ||
final String subscriptionId; | ||
|
||
/// The type of event. | ||
final GraphQLSubscriptionEventType type; | ||
|
||
/// The GraphQL response, if a data event. | ||
final GraphQLResponse<String?>? rawResponse; | ||
|
||
/// Platform error, if an error event. | ||
final ApiException? error; | ||
|
||
/// {@macro graphql_subscription_event} | ||
const GraphQLSubscriptionEvent({ | ||
required this.subscriptionId, | ||
required this.type, | ||
this.rawResponse, | ||
this.error, | ||
}); | ||
|
||
/// Deserializes a platform channel event map. | ||
static GraphQLSubscriptionEvent fromJson(Map json) { | ||
GraphQLResponse<String?>? rawResponse; | ||
final payload = json['payload'] as Map?; | ||
if (payload != null) { | ||
rawResponse = GraphQLResponse.raw( | ||
data: payload['data'] as String?, | ||
errors: (payload['errors'] as List?) | ||
?.cast<Map>() | ||
.map((error) => GraphQLResponseError.fromJson( | ||
error.cast<String, dynamic>(), | ||
)) | ||
.toList(), | ||
); | ||
} | ||
return GraphQLSubscriptionEvent( | ||
subscriptionId: json['id'] as String, | ||
type: GraphQLSubscriptionEventTypeX.fromString(json['type'] as String), | ||
rawResponse: rawResponse, | ||
); | ||
} | ||
} |
Oops, something went wrong.