🔮 Sanity Create is here. Writing is reinvented. Try now, no developer setup

Is There a Way to Dereference (->) Only References?

3 replies
Last updated: Mar 2, 2021
if i have an array that includes both objects and references, is there any way to dereference (
) only the references, while leaving the other elements intact?
Mar 2, 2021, 4:54 PM
schema is an array of
to pages or url-based links (i.e. possibly external):

export default {
  name: "navigation",
  title: "Navigation",
  type: "object",
  fields: [
      type: "array",
      name: "navigation",
      of: [
          title: "Link to page",
          type: "reference",
          to: [{ type: "page" }],
        { title: "External link", type: "navLink" },
          title: "Dropdown menu",
          type: "navigation",
For this, we can ignore the nested array children, I just want to get the info on
references, while also having the
not be sent to null when I deference all children (i.e.
navigation[] ->
I guess the overarching questions is how to use
or other features to conditionally dereference/return projections
Mar 2, 2021, 4:57 PM
😮 i assumed that
_type == ___ =>
statements needed to be in a select! thanks
Mar 2, 2021, 4:59 PM

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?