GROQ language preview
1. Filtering and projections
the everything operator, filters, and projections
horizon-dark
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) atom-one-dark
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) github-dark
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) dracula
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) nord
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) github
*[_type == "movie" && releaseYear >= 2018]{
_id,
title,
releaseYear,
"genres": genres[]->name
} | order(releaseYear desc) 2. Dereferencing and parameters
references, parameters, and joins
horizon-dark
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} atom-one-dark
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} github-dark
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} dracula
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} nord
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} github
*[_type == "author" && _id == $authorId][0]{
name,
"posts": *[_type == "post" && references(^._id)]{
title,
publishedAt
}
} 3. Functions and matching
built-in functions, text matching, and counting
horizon-dark
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
} atom-one-dark
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
} github-dark
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
} dracula
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
} nord
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
} github
{
"featured": *[_type == "post" && featured == true]{ title },
"search": *[_type == "post" && title match "svelte*"]{ title },
"total": count(*[_type == "post"]),
"plain": *[_type == "post"][0]{ "text": pt::text(body) }
}