我是 graphql 的新手。我正在使用 aws appsync 实现一个 react-native 应用程序。以下是我在模式中编写的代码
type Messages {
id: ID!
createdAt: String!
updateAt: String!
text: String!
sendBy: Person!
@relation(name: "UserMessages")}
type Person {
id: ID!
createdAt: String!
updateAt: String!
name: String!
messages: [Messages!]!
@relation(name: "UserMessages")}
当我尝试查询 sendBy 值时,它给了我一个错误说
query getMessages{
getMessages(id : "a0546b5d-1faf-444c-b243-fab5e1f47d2d") {
id
text
sendBy {
name
}
}
}
{
"data": {
"getMessages": null
},
"errors": [
{
"path": [
"getMessages",
"sendBy"
],
"locations": null,
"message": "Cannot return null for non-nullable type: 'Person' within parent 'Messages' (/getMessages/sendBy)"
}
]
}
我不明白那个错误请帮助我。谢谢!提前