我使用amplify cli创建了一个架构,一切正常。问题是,当我尝试在事件模型上执行查询时,即使事件具有注释,它也会将注释带回为null。更让我感到困惑的是,当我仅查询评论时,它们会带回各自的事件,但是当我查询事件时,同样的事情将不起作用。 这是我的以下模式:
type Event @model {
id: ID!
title: String!
latitude: Float!
longitude: Float!
startDate: String!
endDate: String!
description: String!
coverUrl: String!
locationName: String!
Owner: User! @connection
attendies: [User!] @connection
photos: [Photo]
organization: Organization
comments: [Comment] @connection
}
type Comment @model {
id: ID!
user: User! @connection
event: Event! @connection
text: String!
}
我执行的查询是:
列出事件
query listEvents {
listEvents {
items {
title
Owner {
username
}
comments {
items{
text
}
}
}
}
}
将其带回:
{
"data": {
"listEvents": {
"items": [
{
"title": "second Event",
"Owner": {
"username": "likono"
},
"comments": {
"items": []
}
}
]
}
}
}
和列表评论
query listComment{
listComments{
items{
text
event {
title
id
}
}
}
}
带回
{
"data": {
"listComments": {
"items": [
{
"text": "Second Comment Same User Same Event",
"event": {
"title": "second Event",
"id": "8bd6656b-b307-4e8f-ba65-84f75a4c2298"
}
}
]
}
}
}
任何帮助将不胜感激。谢谢。