How AI is powering better personalization in e-commerce [with Vercel]. Sign up now

GROQ query with boolean field works in Vision but returns empty in app

12 repliesLast updated: Dec 1, 2025

hi — can anyone think of why my GROQ query would be returning an empty set in my app but not in the Vision Plugin? My query is
*[ _type == "exhibition" && (!isUpcoming || isUpcoming == null)]
. The query works in the client, returning “exhibitions” if I don’t include the “isUpcoming” conditionals. But then returns an empty set as soon as I add the conditional
AI Update

This is a classic perspective issue! The Vision plugin and your app client are likely querying with different perspectives, which means they're looking at different versions of your documents.

What's happening:

Your isUpcoming field might exist on draft documents but not on published ones (or vice versa). When you add the && (!isUpcoming || isUpcoming == null) filter, the query returns nothing because the documents your app is querying don't have that field in the expected state.

Key things to understand:

How to diagnose:

First, check what perspective your client is using:

const client = createClient({
  // ... other config
  perspective: 'published', // Check what's here (or if it's missing)
})

Then run this in Vision to see which documents have the isUpcoming field and whether they're drafts or published:

*[_type == "exhibition"]{
  _id, 
  isUpcoming, 
  "isDraft": _id in path("drafts.**")
}

This will show you whether isUpcoming exists on drafts, published docs, or both.

Solutions:

Most likely, you need to either publish your exhibition documents so isUpcoming appears on published versions, or configure your client to use a perspective that includes the drafts where isUpcoming is actually set. The difference you're seeing is because Vision and your app may be defaulting to different perspectives, or you have unpublished changes that only exist in draft form.

Show original thread
12 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions