[英]Amplify API GraphQL Circular Resources Dependency
我正在使用生產中的現有放大 graphql api,我的任務是將放大移動到不同的 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")
}
我不確定為什么會觸發循環依賴,起初我以為是屬性類型,但其他 model 工作正常。 你們有什么想法嗎?
這可能不是一個解決方案,但對我來說,重做所有查詢是解決方案,並嘗試以特定順序逐個推送表以放大。 順序是推送類型 A,然后推送僅包含與 A 連接的屬性的數據透視表 AB,然后推送 B,然后使用與 B 連接的屬性更新數據透視表 AB。
我遇到了同樣的問題。 我們有 3 個 Amplify 環境(DEV、TST 和 ACC)。 相同的代碼從 DEV 部署到 TST 再到 ACC。 我們遇到資源之間的循環依賴問題:[預防、用戶配置文件、義務、CustomResourcesjson、記憶、查找、聯系人] - 僅在 TST 環境中,並且僅當我們通過 CICD 部署放大時。 進行放大推送時,一切都會成功。
循環依賴中有問題的資源只有 API @models(表)。
當我們刪除表 #1 (UserProfile) - 然后一切正常。 在 graphql.schema 文件中重新添加表時 - 它再次失敗。
因此 - 通過刪除和讀取模式文件中的表 - 沒有任何區別。 表之間根本沒有依賴關系。
如果有人遇到過這種行為並設法在不刪除 amplify 的情況下解決它,我們將歡迎您的意見。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.