如何在 AWS AppSync 中使用 GraphQL 进行更新突变

问题描述 投票:0回答:1

我尝试在 AWS AppSync 中使用 GraphQL 查询进行更新突变,但运行查询后无法更新数据。 查询如下:

mutation MyMutation($input: UpdateUserInput!) {
  updateUser(input: $input) {
    id
    email
  }
}

查询变量:

{
  "input": {
    "id": "558505e7-c4fd-4af9-81b1-ac407b324d93",
    "email": "[email protected]"
  }
}

结果:

{
  "data": {
    "updateUser": {
      "id": "558505e7-c4fd-4af9-81b1-ac407b324d93",
      "email": "[email protected]"
    }
  }
}

有人遇到过同样的问题吗?

graphql aws-appsync
1个回答
0
投票

对我来说,问题是我安装了版本控制的 DataStore。在这种情况下,为了更新记录,您必须包含当前的_版本号,如下所示:

{
  "input": {
    "id": "558505e7-c4fd-4af9-81b1-ac407b324d93",
    "email": "[email protected]",
    "_version" : 4
  }
}

我在 GraphQL 创建、更新、删除数据文档

中找到了它
© www.soinside.com 2019 - 2024. All rights reserved.