0

我正在尝试编写一个更新 DynamoDB 嵌套对象的 AppSync 解析器。为了创建正确的 UpdateItem 表达式,我必须遍历 $ctx.args 并评估 arg 是否为简单类型,即。包含字符串或 Map 的字段updatedAt 。

我的 $ctx.args:

{
  "cognitoDetails": {
    "cognito__username": "jdoe",
    "given_name": "John"
  },
  "updatedAt": "2021-11-24T10:28:56.429Z"
}

我是我的解析器,在尝试评估时

$util.isMap($ctx.args.cognitoDetails) ## returns true - expected
$util.isMap($ctx.args.updatedAt) ## returns true - unexpected! 

在尝试找到解决此问题的方法时,我还发现:

$util.typeOf($util.time.nowISO8601()) ## returns String which is correct 

#set ( $timestamp = $util.time.nowISO8601() )
$util.typeOf($timestamp) ## returns Map and that is a problem

有人可以指出我正确的方向并解释我在这里做错了什么吗?

4

0 回答 0