AppSync:无法转换为对象

AppSync: Unable to convert to object

我在尝试创建变更时在 AppSync 中遇到此错误:

{
  "data": {
    "sendMessage": null
  },
  "errors": [
    {
      "path": [
        "sendMessage"
      ],
      "data": null,
      "errorType": "MappingTemplate",
      "errorInfo": null,
      "locations": [
        {
          "line": 2,
          "column": 3,
          "sourceName": null
        }
      ],
      "message": "Unable to convert {dealId=312321312312, from=312321313, to=312321312312, id=7e7a8ba9-8e68-425a-9352-4421706c728a, type=text, body=Teste 122, status=sent} to Object."
    }
  ]
}

映射模板:

{
    "version" : "2017-02-28",
    "operation" : "PutItem",
    "key" : {
        "id": $util.dynamodb.toDynamoDBJson($util.autoId()),
    },
    "attributeValues" : $util.dynamodb.toMapValuesJson($ctx.args.input)
}

和突变:

mutation MutationTest {
  sendMessage(input: {dealId: "312321312312", from: "312321313", type: "text", to: "312321312312", status: "sent", body: "Teste 122"})
}

想法?谢谢!

我认为您至少需要一个 return 值,因此您的突变将如下所示:

mutation MutationTest {
  sendMessage(input: {dealId: "312321312312", from: "312321313", type: "text", to: "312321312312", status: "sent", body: "Teste 122"}){
        dealID
    }
}