0

Hey i'm using Sanity and have created both a allSanityPost (for my blog posts) and allSanityCases (for all my cases). Do anyone know how to combine these categories into one array and order them by their "published-date"? I want to display them both on one blog page - but not in separated lists.

I'm building the page with Gatsby, so react answers would be preferable :)

Cheers

1 Answers1

0

The current GraphQL endpoint have no way of querying across documents like GROQ does. Therefore, you will have to do this after querying the GraphQL endpoint for data. I suggest querying for both all posts and all cases separately like this:

query {
  allSanityPost{
    title
  },
  allSanityCases{
    title
  }
}

Given that both of these types have some sort of date, you should be able to combine them into one single array, and then do your sorting thereafter.

Anders Stensaas
  • 749
  • 5
  • 18