【发布时间】:2018-04-12 18:02:43
【问题描述】:
尝试实现join,但总是得到null。
type User {
id: Int!
username: String!
recipes: [Recipe]
}
type Recipe {
id: Int!
title: String!
author: User
}
所以基本上我想得到这样的数据:
User {
username,
recipes: [{//recipe}, {//recipe}]
}
对于我期待的食谱
Recipe {
title,
author: {//user}
}
所以我有如下查询,我想从包含用户的数据库中获取所有食谱
type Query {
recipes: [Recipe!]!
}
这是我的 GraphiQL 查询
{
recipes {
id,
author {
id,
username
}
}
}
但作为回应,我有author: null
{
"data": {
"recipes": [
{
"id": 1,
"author": null
}]
}
}
有什么建议?谢谢!
【问题讨论】:
-
问题很可能与您的解析器有关,而不是您的查询。请更新您的问题以包含您的解析器代码。
-
@DanielRearden,是的,这是解析器的问题,感谢您的回复
标签: graphql graphql-js