We’re open sourcing GROQ: A query language for JSON documents
Blog post from Sanity
Sanity has open-sourced the specification for its query language, GROQ, which is designed for filtering, projecting, and sorting JSON document collections. Originally developed for Sanity’s real-time document store, GROQ allows for complex queries such as filtering posts with specific keywords and ordering results by publish date. As part of the open-source initiative, the working draft of the GROQ specification has been published, and it draws inspiration from GraphQL’s specification format. Magnus Holm, a backend engineer, has been working on Glush, a parsing tool, which facilitates the creation of GROQ parsers for various languages, including JavaScript, and has also developed a CLI tool for querying JSON data through command-line interactions. GROQ's versatility is illustrated through examples such as querying APIs for specific data, counting Pokémon types, and retrieving Nobel Prize laureates based on gender and category. The ongoing development aims to enhance GROQ's capabilities, including its potential use in web browsers, to expand its application beyond Sanity’s ecosystem.