Strapi GraphQL中的嵌套查询

Strapi GraphQL中的嵌套查询,graphql,strapi,Graphql,Strapi,我的文件结构大致如下: post { _id title isPublished } user { _id username name [posts] } 我知道我可以通过聚合子字段查询postConnection和userConnection等字段,以便查询所有对象的计数。但是,如何获得给定用户的所有帖子总数 我能想到这个: { postsConnection(where: {isPublished: true}){ groupBy{ a

我的文件结构大致如下:

post {
  _id
  title
  isPublished
}

user {
  _id
  username
  name
  [posts]
}
我知道我可以通过聚合子字段查询postConnection和userConnection等字段,以便查询所有对象的计数。但是,如何获得给定用户的所有帖子总数

我能想到这个:

{
  postsConnection(where: {isPublished: true}){
    groupBy{
      author{
        key
        connection{
          aggregate{
            count
          }
        }
      }
    }
  }
}
但预期结果是这样的:

{
  "data": {
    "postsConnection": {
      "groupBy": {
        "author": [
          {
            "key": "5c9136976238de2cc029b5d3",
            "connection": {
              "aggregate": {
                "count": 5
              }
            }
          },
          {
            "key": "5c99d5d5fcf70010b75c07d5",
            "connection": {
              "aggregate": {
                "count": 3
              }
            }
          }
        ]
      }
    }
  }
}
如您所见,它返回数组中所有作者的post计数。我需要的是能够返回一个特定用户的计数,而不是通过键字段似乎映射到的_id,而是通过用户集合中的另一个唯一字段,即用户名


可能吗?

需要向查询或字段传入参数以返回特定数据

需要向查询或字段传入参数以返回特定数据