Custom tag system, retrieving how many posts use each tag

I've implemented something referred to here: Create a custom tagging system

I'm using Graphql with the gatsby source prismic plugin, and am wondering what the best way is to determine how many have a tag in their relationship field. So Music has 12 relationships, Movies has 4 etc...

I could just retrieve all posts and just manually count each tag, but there must be a way directly in graphql?

Hi Adam,

You'll want to use the filter by content relationship argument:


Thanks. Had to do it in gatsby-node and create new node fields.

Actually another question I had regarding a custom tag system is that it appears you cannot sortBy with the prismic graphql api?

I know you can with the gatsby-source-prismic plugin, but for a situation where I need runtime queries for a filtering system, there doesnt appear to be a solution.

So you can do sortBy with the GraphQL API,

But not by content relationship.