I develop headless wordpress blogs using nextjs & gatsby and use graphQL as flexible data fetching. For that I'm using wp-graphQL official plugin.
Added an options to get total number of posts, pages or any custome post type of wordpress using grpahQL. This originally given here . But here I coveted into wordpress graphQL plugin.
Total number of pages
{
pages{
pageInfo{
total
}
}
}
Response
{
"data": {
"pages": {
"pageInfo": {
"total": 14
}
}
}
}
Total number of posts
{
posts{
pageInfo{
total
}
}
}
Response
{
"data": {
"posts": {
"pageInfo": {
"total": 14
}
}
}
}