【发布时间】:2021-08-19 03:06:49
【问题描述】:
我正在使用启用了 AppSync 的 Amplify Datastore。数据同步在本地和云端之间工作,但在开发过程中必须执行放大推送以更新云端可能会占用大量时间。
如何关闭 AWS AppSync?
【问题讨论】:
标签: aws-amplify aws-appsync datastore
我正在使用启用了 AppSync 的 Amplify Datastore。数据同步在本地和云端之间工作,但在开发过程中必须执行放大推送以更新云端可能会占用大量时间。
如何关闭 AWS AppSync?
【问题讨论】:
标签: aws-amplify aws-appsync datastore
是的! DataStore 可以在有或没有任何云同步的情况下使用。
在您添加 API 插件时启用云同步。要禁用云同步,请不要添加AWSApiPlugin():
Amplify.addPlugin(AWSDataStorePlugin())
// Comment out this line:
// Amplify.addPlugin(AWSApiPlugin())
Amplify.configure(applicationContext)
存在 API 插件时启用同步。要禁用同步,请不要添加AWSAPIPlugin():
let dataStorePlugin =
AWSDataStorePlugin(modelRegistration: AmplifyModels())
try Amplify.add(plugin: dataStorePlugin)
// Comment out this line:
// try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.configure()
方法略有不同。在 aws-exports.js 文件中查找任何 API 配置,然后将其删除。具体来说,您应该删除前缀中带有aws_appsync_* 的所有配置条目:
const awsmobile = {
// ...
"aws_appsync_graphqlEndpoint": "https://yourid.appsync-api.us-east-1.amazonaws.com/graphql",
"aws_appsync_region": "us-east-1",
"aws_appsync_authenticationType": "AMAZON_COGNITO_USER_POOLS",
// ...
};
【讨论】:
Amplify.configure(awsconfig)吗?还有什么我需要禁用的吗?
似乎DataStore mind set 首先离线,API 可在 AWS 中使用,因此在执行amplify push 时无法在 AWS 中创建 API。
【讨论】:
在开发期间脱机工作的正常解决方案是在项目设置期间不运行amplify push。您可以在本地运行您的应用程序,一切正常,但没有尝试同步到云端。当您更改架构时,您会运行 amplify codegen models,所有模型都会在本地更新。
当您最终准备好部署到云并开始以在线/离线模式运行时,您可以运行 amplify push 来配置所有云资源。即使在此之后,您仍然只能通过使用浏览器开发工具禁用网络连接来在本地运行。
我不知道如何将项目设置回amplify push 之前的状态,但我想要答案。我确定这是项目中放大配置中某处的设置。
【讨论】: