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

demandé il y a un an287 vues
2 réponses
0

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

ignasi
répondu il y a un an
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)"
        }
    ]
}
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions