AWS Amplify CLI生成的GraphQL突变中的$condition输入参数是什么?
我已经从该模型在AWS AppSync(使用CLI)上生成了一个简单的GraphQL API:AWS Amplify CLI生成的GraphQL突变中的$condition输入参数是什么?,graphql,aws-appsync,graphql-mutation,graphql-codegen,Graphql,Aws Appsync,Graphql Mutation,Graphql Codegen,我已经从该模型在AWS AppSync(使用CLI)上生成了一个简单的GraphQL API: type WalletProperty @model { id: ID! title: String! } 这生成了一个CreateWalletProperty、UpdateWalletProperty和DeleteWalletProperty,所有这些都与此类似: mutation CreateWalletProperty( $input: CreateWalletPr
type WalletProperty @model {
id: ID!
title: String!
}
这生成了一个CreateWalletProperty、UpdateWalletProperty和DeleteWalletProperty,所有这些都与此类似:
mutation CreateWalletProperty(
$input: CreateWalletPropertyInput!
$condition: ModelWalletPropertyConditionInput <<<<<<<<<<<< what is this for?
) {
createWalletProperty(input: $input, condition: $condition) {
id
title
createdAt
updatedAt
}
}
考虑到我总是必须提供必需的$input,那么在我的例子中,GraphQL的$condition参数是什么?由DynamoDB表支持 在幕后,GraphQL操作转换为PutItem、UpdateItem和DeleteItem DynamoDB操作 对于这些数据操作,dynamodbapi允许您指定一个条件表达式来确定应该修改哪些项。如果条件表达式的计算结果为true,则操作成功;否则,操作将失败 您可以在AWS上阅读更多关于这些条件的用例 在GraphQL突变级别,只有当记录满足条件时,突变才会继续。否则不允许突变,并返回ConditionalCheckFailedException:
"errors": [
{
"path": [
"deleteWalletProperty"
],
"data": null,
"errorType": "DynamoDB:ConditionalCheckFailedException",
"errorInfo": null,
"locations": [
{
"line": 12,
"column": 3,
"sourceName": null
}
],
"message": "The conditional request failed (Service: DynamoDb, Status Code: 400, Request ID: E3PR9OM6M5J1QBHKNT8E4SM1DJVV4KQNSO5AEMVJF66Q9ASUAAJG, Extended Request ID: null)"
}
]
未标记为wit
代码>则非强制性/非必需。。。用于筛选受影响行的可选参数/items@xadm谢谢我刚刚测试了它,它似乎与输入参数一起应用。考虑到$input已经是强制性的,我想不出一个用例,在这个用例中它实际上是有意义的,或者可以被应用?对于create不是,而是对于update。。。
"errors": [
{
"path": [
"deleteWalletProperty"
],
"data": null,
"errorType": "DynamoDB:ConditionalCheckFailedException",
"errorInfo": null,
"locations": [
{
"line": 12,
"column": 3,
"sourceName": null
}
],
"message": "The conditional request failed (Service: DynamoDb, Status Code: 400, Request ID: E3PR9OM6M5J1QBHKNT8E4SM1DJVV4KQNSO5AEMVJF66Q9ASUAAJG, Extended Request ID: null)"
}
]