Since yesterday from 03:00AM to 18:20PM (UTC+00:00) approximately, we had our app down because of a non announced breaking change in AppSync.
It turns out that, now, the variableMap
JSON of the "Before Mapping Template" no longer accepts to set a property with an array value.
We had to rewrite the queries because we couldn't just do it like follows:
#set($sql = '
SELECT item_id
FROM demo_table
WHERE item_id IN (:ITEM_IDS)
')
{
"version": "2018-05-29",
"statements": [
"$util.escapeJavaScript($sql)"
],
"variableMap": {
":ITEM_IDS": $ctx.args.param_item_ids,
}
}
Instead, we had to figure out how to achieve the same result with an alternative approach, and we came across with the following one based on string searching:
#set($sql = '
SELECT item_id
FROM demo_table
WHERE INSTR(:ITEM_IDS, concat("#", item_id, "#")) > 0
')
[...]
#set($item_ids = "")
#foreach($item_id in $param_item_ids)
#set($item_ids = $item_ids + "#" + $item_id + "#")
#end
[...]
{
"version": "2018-05-29",
"statements": [
"$util.escapeJavaScript($sql)"
],
"variableMap": {
":ITEM_IDS": "$item_ids",
}
}
Okay, it works too. But as you may guess, this is a very simplified query example. The production query is far more complex, and it not only handles one single array param value, but many.
So you can imagine the extra work that it involves to write all this boilerplate just to do a fairy simple WHERE ... IN (...)
.
Apart from the over complexity to write common queries, we are very concerned about another big issue: performance.
With this approach, the internal query analyzer cannot do a good job optimizing the queries since it no longer handles indexed item IDs.
Any clarification about this breaking change would be much appreciated.
Best regards,
Ignasi