【发布时间】:2019-11-02 12:18:21
【问题描述】:
我从 Amplify Cli 为我的 Angular 项目创建 AppSync API。
网站可以订阅 OnChangeListner,其中 DynamoDB 通过突变进行更新。它有效。
async ngOnInit() {
this.api.OnUpdateTableListener.subscribe({
next: resp => {
console.log("update !!!");
console.log("update: " + JSON.stringify(resp));
let update = resp.value.data.onUpdateTable;
this.items = this.items.map(function(a) {
return a.id === update.id ? update : a;
});
}
});
}
async update(selectedItem) {
const update = {
id: selectedItem.id,
status: !selectedItem.status
};
await this.api.UpdateTable(update);
}
但是,我注意到如果我手动更新 DynamoDB,订阅根本不起作用。
关于如何更新 DynamoDB(不是通过突变)和 AppSync 订阅的任何建议仍然有效。
【问题讨论】:
-
我很失望地发现它默认不这样做。当我阅读 AppSync 将支持 graphql 订阅时,我假设它具有连接来自它正在使用的各种数据源的更改的实现......但似乎并非如此。
标签: node.js amazon-dynamodb aws-amplify aws-appsync