如果您遇到“@connection 不能在字段上使用”或“找不到对应的@model指令”的错误,请更改 @connection 的位置。它应该出现在您的 AWS AppSync 数据源名称之后。例如:
type Post @model { id: ID! title: String! comments: [Comment] @connection(name: "PostComments") }
如果您遇到“找不到 @key 所属的 @model”的错误,请添加 @model 指令。例如:
type Post @model { id: ID! title: String! comments: [Comment] @connection(name: "PostComments") @key(fields: ["id", "title"]) }
但是如果您已经在您的类型中使用了 @model,您不需要再次添加它。例如:
type Post @model { id: ID! title: String! comments: [Comment] @connection(name: "PostComments") @key(fields: ["id", "title"]) }
希望这些解决方法对您有帮助。