【问题标题】:How to delete a row from DynamoDB with Amplify?如何使用 Amplify 从 DynamoDB 中删除一行?
【发布时间】:2020-03-28 01:17:33
【问题描述】:

我正在尝试以错误方式运行它:

deletepair = async () => {

    const removePair = {
       id: 'id'
       pairIndex: 1,
    };

    try {
       await API.graphql(graphqlOperation(mutations.removePairItem, {input: removePair}));
       console.log('done')
    }
    catch (err) {
        console.log('error: ', err)
    }   
  }

当我运行 deletepair() 时出现错误:

  error:  TypeError: Must provide Source. Received: undefined

【问题讨论】:

    标签: javascript graphql amazon-dynamodb aws-amplify aws-appsync


    【解决方案1】:

    您的架构文件似乎包含两次Mutation 类型。尝试将其更改为如下所示:

    type Mutation {
      addPairToItem(input: AddPairToItemInput!): Users!
      removePairFromItem(input: RemovePairInput!): Users!
    }
    

    【讨论】:

    • 那推送成功了!我真傻。非常感谢!我只是要对其进行测试,看看索引行是否确实被删除并报告
    猜你喜欢
    • 1970-01-01
    • 2022-12-03
    • 1970-01-01
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-29
    相关资源
    最近更新 更多