You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GROQ-JS is a JavaScript implementation of GROQ which follows the official specification.
import{parse,evaluate}from'groq-js'letinput='*[_type == "user"]{name}'// Returns an ESTree-inspired syntax treelettree=parse(input)letdataset=[{_type: 'user',name: 'Michael'},{_type: 'company',name: 'Bluth Company'},]// Evaluate a tree against a datasetletvalue=awaitevaluate(tree,{dataset})// Gather everything into one JavaScript objectletresult=awaitvalue.get()console.log(result)
The GROQ spec version is independent of the groq-js library version. When you import groq-js you need to be explicit on which GROQ version you want to use. The GROQ version is tied to the groq-spec. This allows us to update the library and its API independent of the GROQ version.
GROQ-JS
GROQ-JS follows SemVer.
See the changelog for recent changes.
This is an "experimental" release and anything may change at any time, but we're trying to keep changes as minimal as possible:
The public API of the parser/evaluator will most likely stay the same in future versions.
The syntax tree is not considered a public API and may change at any time.