groqd
groqd copied to clipboard
groq-builder Make slice(0) nullable by default
Is there an existing issue for this?
- [X] I have searched the existing issues
Code of Conduct
- [X] 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.
This is a great point. I like the idea of adding a .notNull() assertion too!