繁体   English   中英

从 Lambda 调用 AWS AppSync graphql API

[英]Calling AWS AppSync graphql API from Lambda

I am trying to update the value of a table using the AWS-app sync graphql API, I am able to create data and add it in a table using graphql mutation in lambda but when I am trying to update the data its not working. 我从 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 它开始工作了。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM