我正在使用AWS AppSync和Amplify。我的GraphQL模式的片段如下所示:
type Inspection @model {
id: ID!
name: String!
date: AWSDate!
photos: [Photo] @connection(name: "InspectionPhotos")
}
type Photo @model {
id: ID!
inspection: Inspection! @connection(name: "InspectionPhotos")
photo: String!
}
编辑:这是我生成的架构的摘要:
input CreateInspectionInput {
id: ID
name: String!
date: AWSDate!
}
input CreatePhotoInput {
id: ID
photo: String!
photoInspectionId: ID!
}
type Inspection {
id: ID!
name: String!
date: AWSDate!
photos(
filter: ModelPhotoFilterInput,
sortDirection: ModelSortDirection,
limit: Int,
nextToken: String
): ModelPhotoConnection
}
type Photo {
id: ID!
inspection: Inspection!
photo: String!
}
type Mutation {
createInspection(input: CreateInspectionInput!): Inspection
updateInspection(input: UpdateInspectionInput!): Inspection
deleteInspection(input: DeleteInspectionInput!): Inspection
createPhoto(input: CreatePhotoInput!): Photo
updatePhoto(input: UpdatePhotoInput!): Photo
deletePhoto(input: DeletePhotoInput!): Photo
}
我想创建一个新照片,所以我的输入看起来像这样:
CreatePhotoInput createPhotoInput = CreatePhotoInput.builder()
.photoInspectionId(inspectionId)
.photo(getS3Key(localPath))
.build();
但是在下面创建突变时,我得到一个错误,即inspection
中的字段CreatePhotoMutation.CreatePhoto
期望的对象类型为CreatePhotoMutation.Inspection
,而不是字符串。
final CreatePhotoMutation.CreatePhoto expected =
new CreatePhotoMutation.CreatePhoto(
"Photo",
UUID.randomUUID().toString(),
CreatePhotoInput.photoInspectionId(),
CreatePhotoInput.photo());
如何仅通过photoInspectionId执行此突变? 我是否缺少某些东西,因为我是Android和AppSync的初学者...