AWS Amplify部署GraphQL多对多Schema报Expected Name, found @错误如何解决
问题原因
你遇到的报错是典型的GraphQL Schema语法括号不闭合导致的,具体错误点有两个:
- 第一个
@key指令的参数括号未闭合,你写的@key(name: "byUser", fields: ["userID", "communityID"]末尾缺少右括号) - 第二个
@key指令的参数括号同样未闭合,你写的@key(name: "byCommunity", fields: ["communityID","userID"]末尾缺少右括号),直接接了类型定义的大括号{,导致解析器识别语法失败,抛出对应报错。
修正后的完整代码
type UserCommunity @auth @model(queries: null) @key(name: "byUser", fields: ["userID", "communityID"]) @key(name: "byCommunity", fields: ["communityID","userID"]) { id: ID! userID: ID! communityID: ID! user: User! @connection(fields: ["userID"]) community: Community! @connection(fields: ["communityID"]) }
修正后重新部署即可解决该语法报错。
内容的提问来源于stack exchange,提问作者Thomas S.
相关产品推荐
相关产品推荐

