Sanity Query Helper
Description
GROQ can be hard to grok. While GROQ is a really powerful tool, it can be a bit overkill for your most common Sanity operations. To make it easier to query sanity for your content, sanity-query-helper provides an API which might be easier to understand.
Install
yarn add sanity-query-helper
Usage
Immutable. All functions are chainable (except for send) and return a new helper.
const sanityHelper = sanityOptions: projectId: "project-id" dataset: "myDataSet" useCdn: true // Create query // Filtersconst filter = sanityHelper // .compare("releaseDate", SanityQueryHelper.comparisons.greaterOrEqualTo, 1979) // 👈 response from sanity // Picks aka Projectionsfilter // 👈 response with projection // Selectconst select = projection // 👈 response will have 10 first posts (if that many exists) // Order byselect