【发布时间】:2019-06-02 21:20:18
【问题描述】:
鉴于以下 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 进行过滤,这是 Cognito 中属于该组织的一个动态组?尝试使用额外的@model 来帮助使用@auth 规则来保护每个实体,我没有发现任何成功。
【问题讨论】:
-
你能详细说明一下这个问题吗?我不太确定我是否理解。您是否正在尝试查找当前登录用户有权访问哪些组的组织?或者你只是想过滤一个特定的组,单数?
-
我正在尝试查询该用户有权访问的所有组织,然后我想过滤这些结果,以便返回的唯一组织是我拥有或参与的组织该组织的管理员。换句话说,因为
Full-Access-Admin组而返回给我的所有组织,我都想过滤掉。
标签: graphql aws-appsync aws-amplify