
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
This module exports a single function that can be called with an ES2015 template string to signal that it represents a GROQ-query.
The result will be the exact same string as the input, - this is currently helpful for getting syntax highlighting in editors, but in the future it might also parse and validate queries, strip unncessary whitespace and similar.
Pairs well with vscode-sanity!
npm install --save groq
import groq from 'groq'
const query = groq`*[_type == 'products'][0...10]`
If you are using @sanity/codegen
you can use defineQuery
instead of groq
to
get type inference out of the box:
import {defineQuery} from 'groq'
const query = defineQuery(`*[_type == 'products'][0...10]`)
In the future we might merge defineQuery
with groq
, but this is currently not
100% supported by TypeScript.
Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches.
To get started with Sanity, please head over to our getting started guide
MIT-licensed. See LICENSE.
4.11.0 (2025-10-21)
sanity.config
property proper to disable (#10635) (50a2e6e) by Jordan Lawrence (jordanl17@me.com)StringInputPortableText
(be29073) by Ash (ash@sanity.io)GraphQL is a query language for APIs and a runtime for executing those queries by using a type system you define for your data. Unlike GROQ, which is designed for querying JSON documents, GraphQL is more versatile and can be used to query various types of data sources.
JSONPath is a query language for JSON, similar to XPath for XML. It allows you to navigate and query JSON documents. While JSONPath is more focused on navigating JSON structures, GROQ provides more advanced querying capabilities like filtering, ordering, and projections.
Lodash is a JavaScript utility library that provides functions for common programming tasks, including querying and manipulating JSON objects. While Lodash is not a query language, it offers methods that can achieve similar results to GROQ queries through its utility functions.
FAQs
Tagged template literal for Sanity.io GROQ-queries
The npm package groq receives a total of 395,569 weekly downloads. As such, groq popularity was classified as popular.
We found that groq demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 106 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.