1回答
- 新しい順
- 投票が多い順
- コメントが多い順
0
Hi!
I followed the tutorials proposed by 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/
Apparently the problem is that the subscription, not having a DataSource that describes the shape of the object (NoneDS), returns an error because it is not able to ensure that the mandatory fields (id, type and boardId) are always returned.
In fact, directly from the documentation they say:
$context.result: The value returned by the resolver from the data source. The shape of this object depends on the data source and operation.
As workaround it's possible to make the response mapping template of the subscription return a default payload, with the mandatory fields empty (or populated with defaulting).
In this way I actually managed to get the subscription to work.
## 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"} )
回答済み 2年前
Looks like the workaround solves the problem. Thx Riccardo!!!