[英]AWS Amplify dynamic and scalable owner graphql schema
我正在努力尋找一種方法來制作適用於我想使用 AWS Amplify 構建的平台內的多個組織的模型。
用例是一種企業內部網,用戶在平台上注冊並可以訪問工作區。 在工作區中,創建帖子並評論帖子。
這是示例模型:
type Workspace
@model(subscriptions: null)
@auth(
rules: [
{ allow: owner, operations: [create, read], ownerField: "owner" }
{ allow: private, provider: iam, operations: [read, delete] }
]
) {
id: ID!
title: String!
planCode: PlanType!
plan: Plan! @connection(fields: ["planCode"])
posts: [Post]! @connection(name: "workspacePosts", sortField: "createdAt")
totalPosts: Int!
owner: String!
}
type Post
@model(subscriptions: null)
@auth(
rules: [
{ allow: owner, ownerField: "owner", }
]
) {
id: ID!
title: String
workspace: Workspace! @connection(name: "workspacePosts")
comments: [Comment]! @connection(name: "postComments")
totalComments: Int!
owner: String!
}
type Comment
@model(subscriptions: null)
@auth(
rules: [
{ allow: owner, ownerField: "owner", }
]
) {
id: ID!
content: String
post: Post! @connection(name: "postComments")
owner: String!
}
enum PlanType {
FREE
BASIC
PRO
}
帖子、評論和工作區是私有的,只能由工作區所有者查看,工作區所有者也是帖子和評論的所有者。
在某些時候,用戶必須能夠邀請其他用戶進入他的工作區,然后新用戶必須能夠訪問前任所有者生成的所有記錄(工作區、帖子和評論)。
在這種情況下,隨着新用戶的加入,我被迫:
owner: "User_1"
為owner: ["User_1", "User_2"]
與工作區相關的所有內容都必須由添加到工作區的每個新用戶可見或“擁有”。
有沒有更有效的方法?
例如,如果用戶是工作區的所有者,是否可以向工作區添加所有者並自動授予對與工作區相關的所有帖子和評論的訪問權限?
還有其他選擇嗎?
對更有效方法的建議是使用 ControlTower 並且那里的任何規則都適用,特別是如果您想通過 SSO 執行此操作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.