FormidableLabs / groqd

A schema-unaware, runtime and type-safe query builder for GROQ.
https://commerce.nearform.com/open-source/groqd
MIT License
221 stars 17 forks source link

groq-builder: strongly-typed parameters (variables) and conditionals #263

Closed scottrippey closed 5 months ago

scottrippey commented 5 months ago

What

Adds a way to define strongly-typed parameters (aka variables) for a query.

Parameters are required when using the makeSafeQueryRunner runner.

Adds auto-complete support for filters and conditional expressions. For example, .filter(expr) and .conditional({ "expr": ... }) and .select({ "expr": ... }) will now provide auto-suggestions for simple conditional expressions. These methods still accept any string too, and won't error for complex expressions.

Adds a filterBy method, same as filter, but it enforces strongly-typed expressions (only supports simple equality expressions). Eg:

q.parameters<{ slug: string }>()
  .star
  .filterByType('product')
  .filterBy('slug.current == $slug')
vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **groqd** | ⬜️ Ignored ([Inspect](https://vercel.com/formidable-labs/groqd/J2yftFCmo8wF6VHt1hoxsm85PPSA)) | [Visit Preview](https://groqd-git-gb-variables-formidable-labs.vercel.app) | | Feb 6, 2024 3:41pm |