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 Make slice(0) nullable by default #268

Open
2 tasks done
heggemsnes opened this issue Feb 17, 2024 · 1 comment
Open
2 tasks done

groq-builder Make slice(0) nullable by default #268

heggemsnes opened this issue Feb 17, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers groq-builder Related to the newer `groq-builder` package

Comments

@heggemsnes
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Feature Request

Since we are not really reading validation on "min" for arrays, doing slice(0) should always infer to be nullable. 

Also with document queries, i.e:

`const pageQuery = q.star.filterByType("page").filter("slug.current == $slug").slice(0)`

groq will return null if the document doesn't exist. I feel like this should be the default. 

We can add .nullable() but I think it is more correct to make it default nullable in this scenario and perhaps add a .nonNullable() if necessary.
@scottrippey
Copy link
Member

This is a great point. I like the idea of adding a .notNull() assertion too!

@scottrippey scottrippey added enhancement New feature or request good first issue Good for newcomers groq-builder Related to the newer `groq-builder` package labels May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers groq-builder Related to the newer `groq-builder` package
Projects
None yet
Development

No branches or pull requests

2 participants