1回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
【以下的回答经过翻译处理】 我按照AWS提供的教程进行了操作:
- https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-enhanced-filtering.html#aws-appsync-real-time-enhanced-filtering-defining-from-client
- https://aws.amazon.com/blogs/mobile/appsync-enhanced-filtering/
显然,问题出在没有描述对象形状的数据源(NoneDS)的订阅会返回错误,因为它无法确保始终返回必填字段(id、type 和 boardId)。
实际上,直接从文档中,它们说:
$context.result: The value returned by the resolver from the data source. The shape of this object depends on the data source and operation.
为了解决此问题,可以使订阅的response mapping template返回一个默认负载,强制字段为空(或使用默认值填充)。
通过这种方式,我确实成功实现了订阅。
## Response Mapping Template - onUpdateCardDeckByBoardId subscription
$extensions.setSubscriptionFilter({
"filterGroup": [
{
"filters" : [
{
"fieldName" : "boardId",
"operator" : "eq",
"value" : "**** -> a valid board id"
}
]
}
]
})
## Workaround: In case of subscription with custom response template you must provide a valid payload that respects any mandatory fields defined in the model (in this case CardDeck has id, type, boardId and AppSync's default createdAt and updatedAt as mandatory fields).
$util.toJson({"id": "", "type": "", "boardId": "", "createdAt":"1930-01-01T16:00:00-07:00", "updatedAt":"1930-01-01T16:00:00-07:00"} )
関連するコンテンツ
- AWS公式更新しました 3年前