【问题标题】:AppSync: Unable to convert to objectAppSync:无法转换为对象
【发布时间】:2021-02-03 14:03:14
【问题描述】:

我在尝试创建突变时在 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"})
}

想法?谢谢!

【问题讨论】:

    标签: graphql aws-appsync


    【解决方案1】:

    我认为你至少需要一个返回值,所以你的变异应该是这样的:

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

    【讨论】:

      猜你喜欢
      • 2021-05-30
      • 2020-12-20
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      • 2015-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多