Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

GROQ query to get content from movies

By Kapehe & Lo Etheridge

GROQ query to get content from "movie"

*[_type == "movie"]{
  _id,
  title,
  castMembers[]{
    characterName,
    person->
  }
}[0...3]

The GROQ query from the beginner GROQ stream featuring Kapehe and Lauren.

It filters your Content Lake down to all the types that have "movie". We then pulled out the _id, title, and castMembers. Because castMembers is an array, we put an empty array before opening up with curly brackets. We then pulled out characterName and person.

Person is a reference within castMembers so we used the deferencing operator -> to get all the content within that person reference.

The last part of the query, [0...3] is displaying only the first three content items that are returned.

We are following this doc in the stream. And we are using the prebuilt movie Studio that you can find when you run sanity init in your command line.

Contributors

Other schemas by authors