amazon-web-services - AWS Amplify Appsync 在创建具有关系的对象时解决错误
问题描述
我正在尝试创建一个具有关系的对象。
我正在使用自动生成的放大突变
当我创建一个没有关系的对象时,操作成功。当我创建具有关系的对象时,操作失败。
我得到的错误信息是
"The variables input contains a field name 'customer' that is not defined for input object type 'CreateCreditcardInput' "
自动生成的突变如下。
export const createCreditcard = `mutation CreateCreditcard($input: CreateCreditcardInput!) {
createCreditcard(input: $input) {
id
number
expiration
customer {
id
firstName
lastName
phone
address1
address2
city
state
postcode
email
creditcards {
nextToken
}
}
payment {
id
paymentType
creditcard {
id
number
expiration
}
orderAmount
order {
id
date
orderStatus
}
}
}
}
`;
解决方案
解决方案是将包含关系 ID 的属性从嵌套对象更改为字符串。
产生错误的原件是
{id: "", number: 1212112, expiration: "12/20", customer: {id:"81d86584-e031-41db-9c20-e6d3c5b005a6"}}
现在有效的修正是
{id: "", number: 1212112, expiration: "12/20", creditcardCustomerId: "81d86584-e031-41db-9c20-e6d3c5b005a6"}
推荐阅读
- html - 如何在 Office365 的 OWA 任务窗格中换行文本
- python - 如何在 python 脚本运行时同时将输出保存到文件中,即使出现错误?
- fluentvalidation - 在 fluentValidation 中使用必须
- xamarin - 在 Xamarin Android 中找不到 TextInputLayout endIconMode 属性
- nginx - 我们可以为相同的主机名和相同的端口在同一 nginx-server 的不同 Nginx 位置安装不同的 SSL 证书吗?
- java - java.lang.IllegalStateException: : 无法初始化上下文,因为已经存在根应用程序上下文
- excel - 使用 VBA 循环遍历数组,将 Outlook 电子邮件从一个文件夹移动到另一个文件夹?
- docker - 使用 .Net Core Linux Docker 容器中的 jsreport -“不支持在没有 --no-sandbox 的情况下以 root 身份运行”
- css - 水平行中的引导单选按钮和链接
- javascript - 如何使用 ngx-pagination 对 ionic4 应用程序中的数据进行分页?