应用程序同步的Graphql更新语法问题



我不熟悉appsync与graphql的语法。我正在尝试使用应用程序同步更新我的一个实体。我使用了亚马逊的选项来自动分配资源并将它们连接到DynamoDB。这是我的实体:

type Property {
id: ID!
address: String!
listedDate: AWSDate!
notes: String
homeType: String!
tenantName: String!
ownerName: String!
leaseExpDate: AWSDate!
}

在我的突变中,我有这样的:

type Mutation {
updateProperty(input: UpdatePropertyInput!): Property
}

连同此输入:

input UpdatePropertyInput {
id: ID!
address: String
listedDate: AWSDate
notes: String
homeType: String
tenantName: String
ownerName: String
leaseExpDate: AWSDate
}

以下是我对突变的尝试,以更新给定的属性:

mutation updateProperty {
updateProperty(input: UpdatePropertyInput(id: 'myID')) {
address: String!
}
}

我在appsync的文档中找到的最接近的实现可以在这里找到。

输入对象使用如下括号构建:

mutation updateProperty {
updateProperty(input: {
id: "myID",
address: "myAddress"
}) {
address
}
}

以下是一些关于输入对象的附加文档,可以在这里找到:

  • https://graphql.org/learn/schema/#input-类型
  • https://graphql.org/graphql-js/mutations-and-input-types/

最新更新