How to Filter out Null Values using GROQ

3 replies
Last updated: May 24, 2022
πŸ‘‹Can I filter out
values using groq?
I want to use a query like this:

*[_type == "link"] {
But if for instance
is empty/null, it should be filtered out from the result, instead of showing up as
label: NULL
If I do a query like:

*[_type == "link"] {
I get the intended result (except I now query too many unnecessary fields).
May 24, 2022, 9:06 AM
defined(label) => { label }
May 24, 2022, 9:08 AM
Oh, nice πŸ™‚ !
May 24, 2022, 9:10 AM
Thank you!
May 24, 2022, 9:10 AM – build remarkable experiences at scale

Sanity is a customizable solution that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Categorized in