![](/img/trans.png)
[英]How do I get children count in Strapi's one-to-many relation using GraphQL?
[英]strapi & graphql : how to get total count of items?
我正在使用stripi和graphQL ,
通過這個查詢,我可以得到帖子
query {
posts{
id,
title
}
}
我想將帖子和totalCount放在一起,理想的結果是這樣的
{
"data": {
"totalCount" : "3",
"posts": [
{
"id": "1",
"title": "first post "
},
{
"id": "4",
"title": "post two"
},
{
"id": "5",
"title": "post 3"
}
]
}
}
我已經閱讀了文檔,我可以進行查詢以獲取總數,但這對我來說還不夠! 那么,如何將帖子和totalCounts放在一起?
我剛剛發現自己現在處於您的位置,我找到的解決方案是:
query POSTS {
postsConnection {
aggregate {
count
}
}
posts{
id
title
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.