从 Lambda 调用 AWS AppSync graphql API

Calling AWS AppSync graphql API from Lambda

我正在尝试使用 AWS-app sync graphql API 更新 table 的值, 我能够使用 lambda 中的 graphql 突变创建数据并将其添加到 table 但是当我尝试更新数据时它不起作用。 我从 API 网关调用此 lambda 服务。

我将这篇文章引用到代码中 https://cloudonaut.io/calling-appsync-graphql-from-lambda/

我想提到 git 云监视日志中没有错误

这是我的 graphql 的架构

type Mutation {
createLib_content(input: CreateLib_contentInput!): lib_content
    @aws_iam
updateLib_content(input: UpdateLib_contentInput!): lib_content
    @aws_iam
deleteLib_content(input: DeleteLib_contentInput!): lib_content
}

input CreateLib_contentInput {
content: String
userId: String
}

input UpdateLib_contentInput {
content: String
id: ID!
}

创建突变

      graphqlData = await clientDetails.mutate({
    mutation: gql(`
   mutation CreateLibContent($input: CreateLib_contentInput!) {
              createLib_content(input: $input) {
                                      id
                                      content
                                               }
    }`),
    variables: {
      input: {
          content : {},
          userId : identitiesDetails.userId
      }
    },
  });

更新突变

const mutation = gql(`
   mutation UpdateLibContent($input: UpdateLib_contentInput!) {
updateLib_content(input: $input) {
  userId
  content
}
 }`);
  await clientDetails.mutate({
       mutation,
       variables: {
             input: {
                     id : "2947c37e-6f76-40d8-8c10-4cd6190d3597",
                     content : JSON.stringify(event)
                    }
                  }
  }).promise;

感谢@cppgnlearner,您的猜测是正确的。

我刚刚从更新代码中删除了 .promise 它开始工作了。

真不敢相信这么小的事情花了我一整天的时间。