Amplify API GraphQL Circular Resources Dependency



我正在使用生产中的现有amplify graphql api,我的任务是将amplify移动到不同的aws帐户以用于开发目的。我花了大约3天的时间来把事情做好,但当我更新graphql的模式时,我在cli上得到了一个错误

✖ An error occurred when pushing the resources to the cloud
🛑 An error occurred during the push operation: ["Index: 1 State: {"deploy":"waitingForDeployment"} Message: Resource is not in the state stackUpdateComplete"]

查看云形成事件日志,上面写着

Circular dependency between resources: [BuildingAdminBuilding, BuildingAdmin, ConnectionStack, CustomResourcesjson]

上述资源定义为

type BuildingAdminBuilding @model(subscriptions: null) @aws_cognito_user_pools @auth(rules: [
{
provider: apiKey, allow: public, operations: [read, create, update, delete]
},
{
# TODO TEMP ONLY - FOR TESTING UNTIL PROPER GROUPS ARE SETUP
provider: userPools, allow: private, operations: [read, create, update, delete]
},
]) {
id: ID!
buildingAdmin: BuildingAdmin! @auth(rules: [
{
provider: apiKey, allow: public, operations: [read, create, update, delete]
},
{
# TODO TEMP ONLY - FOR TESTING UNTIL PROPER GROUPS ARE SETUP
provider: userPools, allow: private, operations: [read, create, update, delete]
},
]) @connection(name: "BuildingAdminBuilding")
# building: Building! @connection(name: "BuildingBuildingAdmin") @auth(rules: [
#   {
#     provider: apiKey, allow: public, operations: [read, create, update, delete]
#   },
#   {
#     # TODO TEMP ONLY - FOR TESTING UNTIL PROPER GROUPS ARE SETUP
#     provider: userPools, allow: private, operations: [read, create, update, delete]
#   },
# ])
}
type BuildingAdmin
@model(subscriptions: null)
@aws_cognito_user_pools @auth(rules: [
{
provider: apiKey, allow: public, operations: [read, create, update, delete]
},
{
provider: userPools, allow: private, operations: [read, create, update, delete]
}
]) {
id: ID!
user: User @connection(name: "BuildingAdminUser")
buildings: [BuildingAdminBuilding] @auth(rules: [
{
provider: apiKey, allow: public, operations: [read, create, update, delete]
},
{
# TODO TEMP ONLY - FOR TESTING UNTIL PROPER GROUPS ARE SETUP
provider: userPools, allow: private, operations: [read, create, update, delete]
},
])  @connection(name: "BuildingAdminBuilding")
}

我不知道为什么它触发循环依赖,起初我认为这是属性类型,但其他模型工作正常。你们有什么想法吗?

这可能不是一个解决方案,但对我来说,重新执行所有查询是解决方案,并尝试按特定顺序逐个推表以放大。顺序是:push类型A,然后push数据透视表AB,只有与A有连接的属性,然后push B,然后用与B有连接的属性更新数据透视表AB

我也遇到同样的问题。我们有3个放大环境(DEV,TST和ACC)。从DEV到TST再到ACC都部署了相同的代码。我们遇到了一个问题资源之间的循环依赖:[预防,UserProfile,义务,CustomResourcesjson,记忆,查找,联系]-仅在TST环境下,并且仅当我们通过CICD部署放大时。当你做放大推送时,一切都成功了。

在Circular依赖中有问题的资源只有API @models (tables)。

当我们删除表#1 (UserProfile) -然后一切工作。在图中重新添加表时。架构文件-再次失败。

因此——通过删除和读取模式文件中的表——没有任何区别。表之间没有任何依赖关系。

如果有人经历过这种行为,并设法在不删除放大的情况下解决了它,欢迎您的输入。