[Feature Request] Support `amplify mock api`
Updated Description
Updated 05/02/2024 by @Jordan-Nelson
Amplify Flutter does not support amplify mock api. This issue will be used to track interest in this feature request.
Original Description
amplify mock api
The local mock server starts like this and I'm able query the dynamodb from my lambda functions:
Mock does not handle CloudFormation resource of type AWS::IAM::ManagedPolicy. Skipping processing resource.
Running GraphQL codegen
Failed to run GraphQL codegen with following error:
Flutter only supports the command $amplify codegen models. All the other codegen commands are not supported.
AppSync Mock endpoint is running at http://localhost:20002
However, I get this error on the Flutter side when I launch the app even though I followed the instructions here:
Exception has occurred.
ConfigurationError (ConfigurationError {
"message": "Non-HTTPS endpoint found for test_app which is not supported.",
"recoverySuggestion": "Ensure the configured endpoint for test_app utilizes https."
})
Here's how I configure Amplify on Flutter:
if (!Amplify.isConfigured) {
await Amplify.addPlugins([
AmplifyAuthCognito(),
AmplifyDataStore(modelProvider: ModelProvider.instance),
AmplifyAPI(),
]);
await Amplify.configure(amplifyconfig);
debugPrint('Amplify configured successfully.');
} else {
debugPrint('Amplify is already configured.');
}
All amplify libraries I'm using are up-to-date.
The code that causes the issue:
https://github.com/aws-amplify/amplify-flutter/blob/ddafa9a1956303946f91d34cb857732dbeaae17f/packages/api/amplify_api_dart/lib/src/api_plugin_impl.dart#L82C1-L90C6
So, we want to make sure the connection uses https, but it's currently blocking us from connecting to the mock server. Is there a way we can first check if it's not a mock server before verifying the endpoint?
Maybe an additional parameter mockEnabled?
if(!entry.value.mockEnabled && !entry.value.endpoint.startsWith('https')) {
// Throw configuration error
}
I am adding my comment on here to get this prioritised.
Mocking Amplify DataStore using Mockito for Flutter
@afnx @theartofnonso thanks for reporting this, We look into this and get back to you when we have updates. @theartofnonso do you use Amplify DataStore only or do you use Amplify DataStore with Amplify API to sync with cloud?
@afnx This appears to have been a documentation issue, which has since been fixed.
@NikaHsn I use Datastore alongside API to sync to cloud
Any updates on this?
hi, any update?
Hi everyone,
I've implemented a new feature for Amplify CLI, https://github.com/aws-amplify/amplify-cli/pull/13700. You can now enable HTTPS on your mock server! With HTTPS enabled, this error goes away. Your Flutter application will be able to communicate with your test environment.
Upgrade your CLI version and simply use amplify mock api --https /path/to/key /path/to/cert.