groq
TypeScript icon, indicating that this package has built-in type declarations

3.66.1 • Public • Published

GROQ tagged template literal

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!

Installing

npm install --save groq

Usage

import groq from 'groq'

const query = groq`*[_type == 'products'][0...10]`

Automatic type inference

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.

What is Sanity? What is GROQ?

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

License

MIT-licensed. See LICENSE.

Package Sidebar

Install

npm i groq

Weekly Downloads

219,170

Version

3.66.1

License

MIT

Unpacked Size

11.8 kB

Total Files

13

Last publish

Collaborators

  • kmelve
  • bjoerge
  • rexxars
  • skogsmaskin
  • tonina
  • mattcraig
  • joneidejohnsen
  • rubioz
  • robinpyon
  • mariuslundgard
  • sanity-io
  • evenw
  • radhe_sanity
  • rbotten
  • danielsgroves
  • judofyr
  • ryanblock
  • obliadp
  • dcilke
  • madken
  • fredcarlsen
  • hermanw
  • tambet
  • sgulseth
  • atombender
  • simeonsanity
  • stipsan
  • snorreeb
  • rankers
  • rdunk
  • michael-sanity
  • vincentquigley
  • ritasdias
  • kenjonespizza
  • rneatherway-sanity
  • josh_sanity_io
  • cngonzalez-sanity
  • jjburbridge
  • tdfka_rick
  • svirs
  • ryanbonial-sanity
  • indrek.karner
  • ash
  • sergeisarviro
  • refiito
  • drewsanity
  • kaspar.lippmaa.sanity
  • dam
  • simen.svale
  • tbeseda
  • daniel.malmer
  • jordanl17
  • colepeters
  • armandocerna
  • joan_miralles_paez
  • christianhg
  • pedro-sanity
  • jwoods-sanity
  • ricokahler
  • tiit.kass.saity
  • binoy14
  • pauloborgesf
  • ausha
  • nuurtamo
  • chrislarocquesanity
  • simenss