【发布时间】:2022-01-12 01:33:29
【问题描述】:
这样的事情可能吗?这应该如何为这个用例设计?我是否必须添加一个 lambda 函数,以便在创建帖子时将用户 (owner) 添加到帖子中?
谁能帮我完成那个..谢谢!
这是 Post 架构:
type Post
@model
@key(name: "byClub", fields: ["clubId"])
@auth(
rules: [
{ allow: owner, operations: [create, update, delete, read] }
{ allow: private, operations: [read] }
]
) {
id: ID!
content: String!
upVotes: Int!
downVotes: Int!
image: String
clubId: ID!
comments: [Comment] @connection(keyName: "byPost", fields: ["id"])
}
当我获取帖子时,这就是我得到的:
{
"id": "xxxxxxx",
"content": "xxxxx!",
"upVotes": 0,
"downVotes": 0,
"image": null,
"clubId": "xxxxxx",
"comments": {
"nextToken": null
},
"createdAt": "2021-12-05T10:46:59.797Z",
"updatedAt": "2021-12-05T10:46:59.797Z",
"owner": "moneebalalfi@gmail.com"
}
我想要这样的东西:
{
"id": "xxxxx",
"content": "xxxxxxx",
"upVotes": 0,
"downVotes": 0,
"image": null,
"clubId": "xxxxxxxx",
"comments": {
"nextToken": null
},
"createdAt": "2021-12-05T10:46:59.797Z",
"updatedAt": "2021-12-05T10:46:59.797Z",
"owner": {
name: "xxxxx",
email: "xxxx@gmail.com",
image: "xxxxxx",
// and so on ...
}
}
【问题讨论】:
标签: reactjs amazon-web-services next.js amazon-cognito aws-amplify