Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 22 commits into from
Feb 8, 2024

Conversation

scottrippey
Copy link
Member

@scottrippey scottrippey commented Feb 6, 2024

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')

Copy link

vercel bot commented Feb 6, 2024

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

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
groqd ⬜️ Ignored (Inspect) Visit Preview Feb 6, 2024 3:41pm

@scottrippey scottrippey marked this pull request as ready for review February 6, 2024 07:37
@scottrippey scottrippey merged commit 1a5eb69 into main Feb 8, 2024
5 checks passed
@scottrippey scottrippey deleted the gb/variables branch February 8, 2024 00:08
@github-actions github-actions bot mentioned this pull request Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants