【问题标题】:AWS Appsync: how to write mutation update for increment by 1AWS Appsync:如何编写突变更新以增加 1
【发布时间】:2020-01-05 16:08:35
【问题描述】:

我在 dynamo 中成功编写了一个变异查询并更新了值,如下所示:

mutation update {
    updateTodo(input:
        id: “xxxxxxxxx”
        completed: true
    }) {
        id title completed
    }
}

但在表 ToDo 中,我有另一个字段 quantity (Int) 我想增加 1(数量 ++ )。如何编写突变查询来实现它。

欢迎提出任何建议

【问题讨论】:

    标签: graphql aws-appsync


    【解决方案1】:

    在用于突变的 AppSync 解析器中,您可以添加到 DDB UpdateExpression 中,例如“SET 数量 = 数量 + :val”,其中 :val 是您的增量大小(例如 1)。

    更多示例:https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-resolvers.html

    【讨论】:

      猜你喜欢
      • 2018-12-02
      • 2019-04-13
      • 2018-12-21
      • 2019-12-27
      • 2020-05-02
      • 2019-08-21
      • 2020-05-30
      • 2018-11-05
      • 2019-03-05
      相关资源
      最近更新 更多