
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeBased on the context, this statement is part of a discussion about how different Sanity API versions handle empty or unset fields in GROQ queries.
The key difference:
null for empty/unset fields when you explicitly request them in a projectionWhy this happens:
When you write a GROQ query with a projection like *[]{_id, type->name}, you're explicitly asking for those fields. In API versions after v1, GROQ honors this request by including the key in the response even when the value doesn't exist - but it sets it to null rather than omitting it entirely.
This is particularly relevant when:
Solutions to handle this:
Use the coalesce() function to provide fallback values:
*[_type == 'movie']{name, 'rating': coalesce(rating, '')}Add validation rules to make fields required and prevent them from being cleared
Handle null values in your application code when consuming the API response
The original discussion thread also mentions an interesting edge case where the Vision plugin showed correct values while production API calls returned null - this was resolved by adding the specific projection to the webhook query, likely due to API version differences between the two contexts.
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.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store