
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYes, you can selectively dereference only the references in a mixed array! The documented approach is to use conditional projections based on the _type field.
When you have an array containing both inline objects and references, reference objects have _type: "reference" while inline objects have their own _type values. You can use this to conditionally apply the dereference operator:
*[_type == "yourDocType"] {
mixedArray[]{
_type == "reference" => @->,
@
}
}This pattern uses object-level conditional projections where:
@ refers to the current element in the array_type == "reference" and if true, dereferences with @->You can also use the select() function for more explicit conditional logic:
*[_type == "yourDocType"] {
mixedArray[]{
select(
_type == "reference" => @->,
@
)
}
}Both approaches check the _type field to determine whether to dereference. This is particularly useful for page builder arrays or any field that accepts both inline content blocks and references to other documents.
Why this works: References in Sanity are stored as objects with _type: "reference" and a _ref field containing the document ID. The reference access operator (->) only resolves these reference objects, so by checking _type == "reference" first, you ensure dereferencing only happens when appropriate.
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