react-native - 通过 AWS AppSync 中的突变更新 GraphQL 数据时出错
问题描述
我已经使用突变成功创建了数据,但是当我更新该数据时,我收到了这个错误
变量 'input' 已强制 NonNull 类型 'Int! 的 Null 值!
这是我的查询架构
type SmoothstarRegisteration @model @versioned {
id: ID!
active: Boolean!
type: String!
registerationSubmitDate: String
registerationApprovedDate: String
userId: String!
videoInfoReviewed: Boolean!
registerationAttempts: Int!
registerationStatus: String
orderNum: String
orderInfo: OrderInfo @connection(name: "SmoothstarRegisterationOrder")
address: String
postCode: String
region: String
dateOfBirth: String
smoothstarModel: String
purchaseDate: String
shopName: String
ocrInfo: OCRInfo @connection(name: "SmoothstarRegisterationOCR")
privacyPolicyReviewed: Boolean!
extendedPolicyReviewed: Boolean!
termsOfUseReviewed: Boolean!
files: [RegisterationMedia!] @connection(name: "SmoothstarRegisterationMedia")
}
这是更新查询
mutation UpdateSmoothstarRegisteration(
$input: UpdateSmoothstarRegisterationInput!
) {
updateSmoothstarRegisteration(input: $input) {
id
active
type
registerationSubmitDate
registerationApprovedDate
userId
videoInfoReviewed
registerationAttempts
registerationStatus
orderNum
orderInfo {
id
active
type
orderNum
}
address
postCode
region
dateOfBirth
smoothstarModel
purchaseDate
shopName
ocrInfo {
id
active
type
customerId
customerEmail
customerPhone
orderNum
address
}
privacyPolicyReviewed
extendedPolicyReviewed
termsOfUseReviewed
files {
items {
id
version
}
nextToken
}
version
}
}
这是调用API的代码。
return API.graphql(graphqlOperation(operation, data))
.then(response => {
console.log(`API (${name}) Response => `, response);
return response;
})
.catch(error => {
throw error;
});
在Operation
我发送更新查询时,我在数据中放置
{ input: {
active: true
extendedPolicyReviewed: true
id: "9dfc480f-7bed-42ed-a585-820f5e8c1485"
orderNum: "ABCD1234xyz"
privacyPolicyReviewed: true
registerationAttempts: 2
registerationStatus: "registered"
registerationSubmitDate: "2019-03-31"
smoothstarRegisterationOrderInfoId: "03b6967d-4b86-4c2d-9115-fb7a40a9c474"
termsOfUseReviewed: true
type: "W"
userId: "m.daniyal.awan@gmail.com"
videoInfoReviewed: true
}}
解决方案
我已经解决了这个问题,expectedVersion
输入中缺少属性。刚刚添加expectedVersion: 1
,很高兴。该数字必须与当前数据中存在的版本条目完全相同,每次调用更新时都必须增加它。
推荐阅读
- python - 如何在 Tornado Web 服务中达到异步请求的目的
- python - 在 python 中读取 csv 文件时附加到混合的二维数组
- mysql - 根据当前选择添加额外的商店过滤器
- java - AWS Kinesis - 如何从上一个检查点恢复消费
- asp.net-core - 在 ASP.NET Core 的类库中使用 Identity DbContext 和 DbContext
- javascript - 正则表达式 windows 路径验证器
- docker - 在 docker 容器中构建 SSIS 项目
- python - 返回该类的所有实例的另一个方法返回的值的总和?
- mysql - 如何以 24 小时计算显示时间结果
- windows - 从 windows-host 上的 windows-box 访问共享的 vagrant-folder 而不使用“net use”