-
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
chore(api): update endpoint config to use ApiOutputs instead of AWSApiConfig type #5193
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:amplify_core/amplify_core.dart'; | ||
|
||
/// {@template amplify_core.amplify_outputs.data_outputs} | ||
/// The Rest API and GraphQL category Outputs. | ||
/// {@endtemplate} | ||
abstract interface class ApiOutputs { | ||
String get awsRegion; | ||
String get url; | ||
String? get apiKey; | ||
APIAuthorizationType get authorizationType; | ||
ApiType get apiType; | ||
} | ||
|
||
enum ApiType { | ||
rest, | ||
graphQL, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:amplify_core/amplify_core.dart'; | ||
import 'package:amplify_core/src/config/amplify_outputs/api_outputs.dart'; | ||
|
||
part 'data_outputs.g.dart'; | ||
|
||
|
@@ -10,7 +11,8 @@ part 'data_outputs.g.dart'; | |
/// {@endtemplate} | ||
@zAmplifyOutputsSerializable | ||
class DataOutputs | ||
with AWSEquatable<DataOutputs>, AWSSerializable, AWSDebuggable { | ||
with AWSEquatable<DataOutputs>, AWSSerializable, AWSDebuggable | ||
implements ApiOutputs { | ||
/// {@macro amplify_core.amplify_outputs.data_outputs} | ||
const DataOutputs({ | ||
required this.awsRegion, | ||
|
@@ -24,12 +26,15 @@ class DataOutputs | |
_$DataOutputsFromJson(json); | ||
|
||
/// The AWS region of Amazon AppSync resources. | ||
@override | ||
final String awsRegion; | ||
|
||
/// The AppSync endpoint URL. | ||
@override | ||
final String url; | ||
|
||
/// The AppSync API Key. | ||
@override | ||
final String? apiKey; | ||
|
||
/// The default authorization type for AWS AppSync. | ||
|
@@ -38,6 +43,13 @@ class DataOutputs | |
/// List of supported authorization types for AWS AppSync. | ||
final List<APIAuthorizationType> authorizationTypes; | ||
|
||
@override | ||
ApiType get apiType => ApiType.graphQL; | ||
|
||
@override | ||
APIAuthorizationType<AmplifyAuthProvider> get authorizationType => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: missing doc comment |
||
defaultAuthorizationType; | ||
|
||
@override | ||
List<Object?> get props => [ | ||
awsRegion, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:amplify_core/amplify_core.dart'; | ||
import 'package:amplify_core/src/config/amplify_outputs/api_outputs.dart'; | ||
|
||
part 'rest_api_outputs.g.dart'; | ||
|
||
|
@@ -13,7 +14,8 @@ part 'rest_api_outputs.g.dart'; | |
/// {@endtemplate} | ||
@zAmplifyOutputsSerializable | ||
class RestApiOutputs | ||
with AWSEquatable<RestApiOutputs>, AWSSerializable, AWSDebuggable { | ||
with AWSEquatable<RestApiOutputs>, AWSSerializable, AWSDebuggable | ||
implements ApiOutputs { | ||
/// {@macro amplify_core.amplify_outputs.rest_api_outputs} | ||
const RestApiOutputs({ | ||
required this.awsRegion, | ||
|
@@ -25,18 +27,25 @@ class RestApiOutputs | |
factory RestApiOutputs.fromJson(Map<String, Object?> json) => | ||
_$RestApiOutputsFromJson(json); | ||
|
||
/// The AWS region of Amazon AWS Gateway resources. | ||
/// The AWS region of Amazon API Gateway resources. | ||
@override | ||
final String awsRegion; | ||
|
||
/// The AWS Gateway endpoint URL. | ||
/// The Amazon API Gateway endpoint URL. | ||
@override | ||
final String url; | ||
|
||
/// The AppSync API Key. | ||
/// The Amazon API Gateway API Key. | ||
@override | ||
final String? apiKey; | ||
|
||
/// The authorization type. | ||
@override | ||
final APIAuthorizationType authorizationType; | ||
|
||
@override | ||
ApiType get apiType => ApiType.rest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this is missing its docs comment. Same with the |
||
|
||
@override | ||
List<Object?> get props => [ | ||
awsRegion, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ import 'package:amplify_api_dart/src/graphql/web_socket/types/connectivity_platf | |
import 'package:amplify_api_dart/src/graphql/web_socket/types/subscriptions_event.dart'; | ||
import 'package:amplify_api_dart/src/graphql/web_socket/types/web_socket_types.dart'; | ||
import 'package:amplify_core/amplify_core.dart' hide SubscriptionEvent; | ||
// ignore: implementation_imports | ||
import 'package:amplify_core/src/config/amplify_outputs/api_outputs.dart'; | ||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Needing this ignore seems odd, are we sure this is the best way to import/export this type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the way we do in the monorepo when we do not want to export files/types from one package but still want to use them in other packages. |
||
import 'package:async/async.dart'; | ||
import 'package:meta/meta.dart'; | ||
import 'package:stream_transform/stream_transform.dart'; | ||
|
@@ -26,7 +28,7 @@ part '../types/web_socket_event.dart'; | |
class WebSocketBloc with AWSDebuggable, AmplifyLoggerMixin { | ||
/// {@macro api.web_socket_bloc} | ||
WebSocketBloc({ | ||
required AWSApiConfig config, | ||
required ApiOutputs config, | ||
required AmplifyAuthProviderRepository authProviderRepo, | ||
required WebSocketService wsService, | ||
required GraphQLSubscriptionOptions subscriptionOptions, | ||
|
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.
Question: Does this get included in the json serialization/de-serialization? I don't see the generated file changed, but that could just be caused by codegen not being run
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.
code gen does not change the generated codes, I think this is because they are getters.