-
Notifications
You must be signed in to change notification settings - Fork 260
chore(api): update endpoint config to use ApiOutputs instead of AWSApiConfig type #5193
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/amplify_core/lib/src/config/amplify_outputs/api_outputs.dart
This file contains hidden or 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,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, | ||
} |
This file contains hidden or 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 |
---|---|---|
|
@@ -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,15 @@ class DataOutputs | |
/// List of supported authorization types for AWS AppSync. | ||
final List<APIAuthorizationType> authorizationTypes; | ||
|
||
/// The GraphQL Api type. | ||
@override | ||
ApiType get apiType => ApiType.graphQL; | ||
|
||
/// The default authorization type. | ||
@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, | ||
|
This file contains hidden or 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 |
---|---|---|
|
@@ -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,26 @@ 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; | ||
|
||
/// The Rest Api type. | ||
@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, | ||
|
3 changes: 3 additions & 0 deletions
3
packages/amplify_core/test/config/amplify_outputs_mapping/amplify_outputs_mapping_test.dart
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.