FormidableLabs / groqd

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

Feature: Groq builder 0.1 #239

Closed scottrippey closed 10 months ago

scottrippey commented 11 months ago

What is groq-builder?

This new package is a potential successor to groqd. It has 2 main features:

  1. Schema-aware strongly-typed Groq queries. This provides a better developer experience when writing GROQ (auto-complete) and validates your queries against your schema (via TypeScript).
  2. Runtime validation is optional. Zod is no longer bundled, but is extremely easy to utilize.

Why a new package?

Instead of creating this as a GroqD v2, it seemed appropriate to publish as a new package. While the syntax is extremely similar, and it ought to be easy to upgrade, there's no code reuse. And GroqD is hard to say 😝

This is an Alpha release

This PR is introducing the package, so this is considered an alpha release. It is not yet feature complete, but will be soon.

TODO:

vercel[bot] commented 11 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/RvcFhjAV5YUYhK261eALJvyn3U7o)) | [Visit Preview](https://groqd-git-groq-builder-formidable-labs.vercel.app) | | Nov 23, 2023 7:43pm |
danteissaias commented 10 months ago

The way the types are defined in the build output (declare module "../groq-builder") causes typescript not to associate those types with the groq-builder module.

scottrippey commented 10 months ago

@danteissaias Thanks for pointing that out! I switched the build to use tsc instead of tsup and it builds correctly now.

saiichihashimoto commented 10 months ago

I'm pretty sure this is the wrong place to put this, but I moved the expectType code into https://www.npmjs.com/package/@saiichihashimoto/test-utils so I can reuse it. I think there were some improvements since you copied it, might be worth importing it directly.

Also, looking forward to this! Runtime validating GROQs sounds very big.

scottrippey commented 10 months ago

@saiichihashimoto I was just talking today about your expectType utility and how much I loved it! I'll look into migrating to the package!