
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe issue you're experiencing is that when you use contentLoggedIn[] -> at the array level, GROQ tries to dereference every item in the array. This works fine for references (items with a _ref field), but returns null for inline objects that aren't references.
The reference access operator (->) only works on reference objects. When applied to non-reference inline objects like your dynamicSlider, it returns null.
Remove the -> from the array level and only apply it where you actually have references:
contentLoggedIn[] {
_type == 'staticSlider' => {
_type,
_key,
textIsCentered,
textColor,
header {
headline,
body,
callToAction {
text,
link
}
},
items[] -> {
title,
filterUrl,
urlSlug,
image {
"asset": {
"url": asset->url
}
},
description
}
},
_type == 'dynamicSlider' => {
_type,
content
}
}This works because:
contentLoggedIn[] without -> processes each item in the array as-isstaticSlider and dynamicSlider items (which appear to be inline objects based on your projection), you access their fields directlyitems[] array within staticSlider appears to contain references, so you use -> there specificallyIf your contentLoggedIn array actually contains some items that are references and some that are inline objects, you'll need to handle them differently. Based on the Sanity community answer on mixed content, you can manually check each type:
contentLoggedIn[] {
_type == 'staticSlider' => @->{
_type,
_key,
textIsCentered,
textColor,
header {
headline,
body,
callToAction {
text,
link
}
},
items[] -> {
title,
filterUrl,
urlSlug,
image {
"asset": {
"url": asset->url
}
},
description
}
},
_type == 'dynamicSlider' => @{
_type,
content
}
}In this pattern, @ represents the current item. If staticSlider items are references, use @-> to dereference them. If dynamicSlider items are inline objects, use @ to access them directly.
However, based on your original query structure where you're projecting specific fields from both types, it's most likely that both are inline objects in your array, making the first solution the correct one.
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