【发布时间】:2020-10-25 14:49:27
【问题描述】:
背景:
我正在使用 Amplify 创建一个带有 @auth allow owner 的 type Item @model GraphQL 数据存储,它将所有者作为 CognitoID 添加到项目中。
问题: 此项目可供客人阅读,我想显示此项目的所有者(或其他相关元数据,如用户名/电子邮件)。
例如Cognito.GetUserAttributes(2b10fb7e-4472-43c9-9bb9-54219b5027a3)
这样的事情可能吗?这应该如何为这个用例设计?我是否必须添加一个 lambda,以便在创建项目时将用户元数据添加到项目中?
我希望此解决方案具有可扩展性。
架构:
type Item
@model
@auth(rules: [
{ allow: owner},
{ allow: groups, groups: ["Admin"] },
{ allow: private, operations: [read] },
{ allow: public, operations: [read] }
])
{
id: ID!
title: String!
description: String
}
来自 DynamoDB:
{
"__typename": "Item",
"_lastChangedAt": 1593707126605,
"_version": 1,
"createdAt": "2020-07-02T16:25:26.582Z",
"description": "Description",
"id": "0592fcd8-408e-406e-84bf-9f63eb43e147",
"owner": "2b10fb7e-4472-43c9-9bb9-54219b5027a3",
"title": "Item",
"updatedAt": "2020-07-02T16:25:26.582Z"
}
【问题讨论】:
标签: amazon-web-services amazon-cognito aws-amplify