AWS AppSync,通过@connection过滤列表

时间:2019-01-09 04:19:41

标签: graphql aws-appsync

我正在使用AWS-Amplify构建一个项目管理应用程序。我有一个称为“公司”的顶级类型:

type Company @model @auth(rules: [ { allow: groups, groups: ["SUPERUSER", "ADMIN"], queries: [get, list], mutations: [create, update, delete] }, { allow: groups, groups: ["MANAGER, CONTRACTOR, CONSULTANT"], queries: [get], mutations: null } ] ) { id: ID! title: String! projects: [Project] @connection(name: "CompanyProjects") }

它包含项目列表,另一种类型:

type Project @model @auth(rules: [ { allow: owner }, { allow: groups, groups: ["SUPERUSER", "ADMIN", "MANAGER"], queries: [get, list], mutations: [create, update] }, { allow: groups, groups: ["CONTRACTOR", "CONSULTANT"], queries: [get, list], mutations: [update] }, ] ) { id: ID! company: Company! @connection(name: "CompanyProjects") createdOn: String! title: String! status: CompletionStatus! description: String documents: [Document] @connection(name: "ProjectDocuments") }

如何在诸如listProjects之类的查询过程中正确使用过滤条件,以确保当前用户仅获得与其所属公司相关的项目?

0 个答案:

没有答案