[英]Querying many to many relation graphql
我的模型中有多对多关系:
帖子有很多类别,类别可能有很多帖子type Post { id: Int, userId: Int, title: String, category: [Category] }
createdAt | updatedAt | categoryId | postId
---------------------------- + --------------------- ------- + ------------ + -------- 2018-08-23 01:47:42.305 + 04 | 2018-08-23 01:47:42.305 + 04 | 1 | 2
通过PostCategories表。
当我尝试查询帖子中的类别即时通讯作为结果获取null时,查询:
{
post(id:2){
category {
name
}
}
}
结果:
{
"data": {
"post": {
"category": null
}
}
}
问题是,什么即时通讯做错了,我应该添加自定义解析器,它将通过postId获取所有类别。
这在github中得到了回答,但是基本上category字段没有解析器!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.