给定以下AWS Amplify GraphQL架构( schema.graphql
):
type Organization
@model
@auth(rules: [
{ allow: groups, groups: ["Full-Access-Admin"], mutations: [create, update, delete], queries: [list, get] },
{ allow: owner },
{ allow: groups, groupsField: "orgAdminsCognitoGroup", mutations: null, queries: [list, get] }
]) {
id: ID!
name: String!
address: String!
industry: [String]!
owner: String
orgAdminsCognitoGroup: String
}
我可以通过以下方法过滤掉除属于当前经过身份验证的用户的组织以外的所有组织:
res = await API.graphql(graphqlOperation(listOrganizations, {
// todo: filter by owner OR by is org admin
filter: {
owner: {
eq: this.props.currentUser.username
}
}
}));
但是是否还需要通过orgAdminsCognitGroup
进行过滤, orgAdminsCognitGroup
是Cognito中属于该组织的动态组? 我没有发现尝试使用其他@model
帮助@auth
规则来保护每个实体的任何成功。