variableMap in AppSync Resolvers no longer accepts array values

0

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

질문됨 일 년 전286회 조회
2개 답변
0

SOLVED: We have noticed that, luckily, you have reverted that change, because the WHERE ... IN (...) clause can be used again.

ignasi
답변함 일 년 전
0

BROKEN AGAIN: Really? After two weeks, ARRAYS are no longer accepted again. We get this error message:

{
    "data": {
        "data": null
    },
    "errors": [
        {
            "path": [
                "data"
            ],
            "data": null,
            "errorType": "MappingTemplate",
            "errorInfo": null,
            "locations": [
                {
                    "line": 2,
                    "column": 3,
                    "sourceName": null
                }
            ],
            "message": "Variables-map values must be either of type String, Boolean, Double, Integer, Long, or null. (you provided ARRAY)"
        }
    ]
}
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠