# groqd

> GroqD is a GROQ query builder, designed to give the best GROQ developer experience possible, with the flexibility of GROQ, the runtime safety of Zod, and provides schema-aware auto-completion and type-checking.

Latest version **1.7.1** (published 2025-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install groqd
pnpm add groqd
yarn add groqd
bun add groqd
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; has provenance; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.1 |
| Published | 2025-05-20 |
| First published | 2022-11-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 14 |
| Dependencies | 2 |
| Unpacked size | 186.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 293 |
| Author | Formidable |
| Maintainers | michaelmerrill, sarmeyer, mariano-formidable, ryan.roemer, formidable-owner, formidablelabs, carbonrobot, masiddee, scott-rippey, sarahformidable, robwalkerco, ceceppa, keithluchtel, scottianstewart, gksander |
| Keywords | sanity, groq, query, typescript |

## Links

- npm: https://www.npmjs.com/package/groqd
- Repository: https://github.com/FormidableLabs/groqd
- Homepage: https://github.com/formidablelabs/groqd
- Issues: https://github.com/FormidableLabs/groqd/issues
- npm.io page: https://npm.io/package/groqd

## Dependencies (2)

- [zod](https://npm.io/package/zod.md) ^3.22.4
- [type-fest](https://npm.io/package/type-fest.md) ^4.10.1

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.7.1 (latest) — 2025-05-20
- 0.15.13 (legacy) — 2025-04-11
- 1.7.0 — 2025-05-13
- 1.6.0 — 2025-04-30
- 1.5.0 — 2025-04-25
- 1.4.0 — 2025-04-15
- 1.3.1 — 2025-04-14
- 0.15.13-legacy.0 — 2025-04-11
- 1.3.0 — 2025-02-25
- 1.2.0 — 2025-02-19
- 1.1.0 — 2025-02-18
- 1.0.9 — 2025-02-11
- 1.0.8 — 2025-02-10
- 1.0.7 — 2025-02-10
- 1.0.6 — 2025-02-04
- … 52 more at https://npm.io/package/groqd/versions

## README

[![GROQD](https://oss.nearform.com/api/banner?badge=groqd&bg=c99f46)](https://commerce.nearform.com/open-source/groqd)

**[Check out the official documentation.](https://commerce.nearform.com/open-source/groqd)**

`groqd` is a schema-unaware, runtime-safe query builder for [GROQ](https://www.sanity.io/docs/groq). **The goal of `groqd` is to give you (most of) the flexibility of GROQ, with the runtime/type safety of [Zod](https://github.com/colinhacks/zod) and TypeScript.**

`groqd` works by accepting a series of GROQ operations, and generating a query to be used by GROQ and a Zod schema to be used for parsing the associated GROQ response.

An illustrative example:

```ts
import { q } from "groqd";

// Get all of the Pokemon types, and the Pokemon associated to each type.
const { query, schema } = q("*")
  .filter("_type == 'poketype'")
  .grab({
    name: q.string(),
    pokemons: q("*")
      .filter("_type == 'pokemon' && references(^._id)")
      .grab({ name: q.string() }),
  });

// Use the schema and the query as you see fit, for example:
const response = schema.parse(await sanityClient.fetch(query));

// At this point, response has a type of:
// { name: string, pokemons: { name: string }[] }[]
// 👆👆
```

## Support

Have a question about Groqd? Submit an issue in this repository using the
["Question" template](https://github.com/FormidableLabs/groqd/issues/new?template=question.md).

Notice something inaccurate or confusing? Feel free to [open an issue](https://github.com/FormidableLabs/groqd/issues/new/choose) or [make a pull request](https://github.com/FormidableLabs/groqd/pulls) to help improve the documentation for everyone!

The source for our docs site lives in this repo in the [`docs`](https://github.com/FormidableLabs/groqd/blob/main/website/docs) folder.

## Contributing

Please see our [contributing guide](CONTRIBUTING.md).

## Maintenance Status

**Active:** Nearform is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.

---
_Source: https://npm.io/package/groqd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
