๐Ÿ”ฎ Sanity Create is here. Writing is reinvented. Try now, no developer setup

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

Sanityโ€“ build remarkable experiences at scale

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

Was this answer helpful?