GROQ - Graph Oriented Query Language, is a general purpose query language and can query any collection of unstructured JSON-documents without any up-front configuration.
GROQ - Graph Oriented Query Language
GROQ is developed by SANITY.io as is used to query data either hosted with SANITY or self-hosted. You usually write the queries in Content Studio and display the data in your front-end (vue.js, react, angular etc.).
Join together information from several sets of documents. Stitch together a very specific response the exact fields you need.
- Follow references
- Relational joins on key-value data
- Get exactly the data structures you need by reprojecting attributes
- Bundle multiple queries in the same request and get it all cached.
- Query on structured block text
Everything:
*
Movies released after 1979
*[_type == 'movie' && releaseYear > 1979]
… ordered by release year and only certain fields
*[_type == 'movie' && releaseYear >= 1979]
| order(releaseYear) {
_id, title, releaseYear
}
Get actors and join in arrays of the titles of the movies they played in
*[_type == "person"]{
_id, name,
"movies":
*[
_type == "movie"
&& references(^._id)
].title
}