0

我正在使用strapigraphQL

通过这个查询,我可以获得帖子

query {
  
  posts{
    id,
    title
  }
}

我想把帖子总计数 放在一起,理想的结果是这样的

{
  "data": {

"totalCount" : "3",
    "posts": [
      {
        "id": "1",
        "title": "first post "
      },
      {
        "id": "4",
        "title": "post two"
      },
      {
        "id": "5",
        "title": "post 3"
      }
    ]
  }
}

我已经阅读了文档,我可以查询总计数,但这对我来说还不够!那么,我怎样才能将帖子总计数放在一起?

4

1 回答 1

3

我现在刚刚发现自己处于你的位置,我找到的解决方案是:

    query POSTS {
      postsConnection {
        aggregate {
          count
        }
      }
      posts{
        id
        title
      }
    }
于 2021-11-09T01:58:33.207 回答