Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Hey all, let’s say I have content types ‘StandardPost’ and ‘ReviewPost’. They are identical except review post has the extra fields ‘rating’, ‘pros’ and ‘cons’. I want my...

6 replies
Last updated: Nov 1, 2020

Hey all, let’s say I have content types ‘StandardPost’ and ‘ReviewPost’. They are identical except review post has the extra fields ‘rating’, ‘pros’ and ‘cons’. I want my Category pages to list and sort all posts, regardless of whether they are StandardPost or ReviewPost. Would the following GROQ query be valid and accomplish this?
*[_type == “standardPost” || _type == “reviewPost”] | order(_createdAt desc)

If it does, that’d be awesome. AFAIK sorting wouldn’t be possible with GraphQL unless you wrap them in a ‘Post’ type which would reference reviewPost or standardPost (really messy).

Nov 1, 2020, 4:28 PM

It looks like it should. You can try out the query using Vision (


Nov 1, 2020, 4:30 PM


user A
. I haven't actually started using Sanity (I'm considering it for this reason, actually). But from the playground, it seems possible. However, I take it this would mean I'd have to stay away from Gatsby as that enforces the GraphQL API

Nov 1, 2020, 4:40 PM

I see. I decided on Sanity over a few others and have been very happy with it so far. I’ve never used this plugin personally as I haven’t built anything with Gatsby and Sanity, but this may be worth checking out:

Nov 1, 2020, 4:44 PM

Interesting. I prefer to stick with official libraries so I think I'll skip Gatsby, since I was already planning to try something on the new release of NextJS

Nov 1, 2020, 4:56 PM

Your query will work but you can simplify it like this

*[_type in ["standardPost", "reviewPost"]]

Nov 1, 2020, 5:17 PM

user J
sweet, thanks!

Nov 1, 2020, 6:24 PM Get the most out of your content is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Free to get started, pay-as-you-go on all plans.