Aws lambda Appsync和x27;Don’我不能坚持下去

Aws lambda Appsync和x27;Don’我不能坚持下去,aws-lambda,graphql,amazon-dynamodb,serverless-framework,aws-appsync,Aws Lambda,Graphql,Amazon Dynamodb,Serverless Framework,Aws Appsync,我有一个Lambda函数,它使用Cognito的post-confirmation触发器将用户初始化到DynamoDB表中 该表的配置如下: UsersTable: Type: AWS::DynamoDB::Table Properties: BillingMode: PAY_PER_REQUEST KeySchema: - AttributeName: id KeyType: HASH Attribut

我有一个Lambda函数,它使用Cognito的post-confirmation触发器将用户初始化到DynamoDB表中

该表的配置如下:

  UsersTable:
    Type: AWS::DynamoDB::Table
    Properties:
      BillingMode: PAY_PER_REQUEST
      KeySchema:
        - AttributeName: id
          KeyType: HASH
      AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
      Tags:
        - Key: Environment
          Value: ${self:provider.stage}
        - Key: Name
          Value: ${self:app}-${self:provider.stage}-users-table
我有一个Appsync实例,该表被配置为以下架构的数据源:

type MyProfile implements IProfile {
  id: ID!
  email: AWSEmail!
  username: String

  name: String
  surname: String

  birthdate: AWSDate
  signupdate: AWSDateTime!
  imageURL: AWSURL

  city: String
  status: String

}
我能够通过Appsync运行GraphQL查询和突变,但不幸的是,它们似乎不能正确地在DynamoDB上持久化。 当我执行变异时,将应用以下模板:

{
    "version" : "2018-05-29",
    "operation" : "UpdateItem",
    "key" : {
        "id" : $util.dynamodb.toDynamoDBJson($context.identity.username)
    },
    "update" : {
        "expression" : "set #name = :name, surname = :surname, username = :username, birthdate = :birthdate, imageURL = :imageURL, city = :city, #status = :status",
        "expressionNames" : {
           "#name" : "name",
           "#status" : "status"
       },
       "expressionValues" : {
           ":name" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.name),
           ":surname" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.surname),
           ":username" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.username),
           ":birthdate" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.birthdate),
           ":imageURL" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.imageURL),
           ":city" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.city),
           ":status" : $util.dynamodb.toDynamoDBJson($context.arguments.newProfile.status),
       }
    },
    "condition" : {
        "expression" : "attribute_exists(id)"
    }
}
当我运行时,修改后的参数从Appsync正确返回,它们出现在DynamoDB上

当我在同一个用户上运行另一个变异时,问题就出现了:在DynamoDB上,在第一个变异中修改的字段被重置为null,而在第二个变异中修改的字段在DynamoDB上被正确修改并正确返回

这让我头疼,我错过了什么


提前感谢,祝您度过愉快的一天

在调用更新时,请尝试给出对象的当前“\u version”值