Help with setting initial values for array of references in Sanity schema
Looking at your query, the issue is that you're creating an extra layer of nesting. When you query *[_type == "person"] and then project each result with an authors object, you're wrapping each reference inside an authors property.
If you want to create an array of reference objects from all person documents, you need:
*[_type == "person"]{
"_type": "reference",
"_key": _id,
"_ref": _id
}This gives you a flat array of reference objects without the extra authors wrapper.
However, I suspect what you're actually trying to do is query documents that already have an authors array and either:
1. Get the raw reference structure (as stored):
*[_type == "yourDocumentType"]{
authors
}This returns the authors array exactly as you showed it, with _type, _key, and _ref.
2. Dereference the authors to get their actual data:
*[_type == "yourDocumentType"]{
authors[]->{
name,
bio,
// other person fields
}
}The []-> syntax dereferences the entire array, replacing each reference with the actual person document.
3. Dereference but keep the _key property:
*[_type == "yourDocumentType"]{
authors[]{
_key,
...(@->{
name,
bio
})
}
}This pattern preserves the _key while spreading the dereferenced content, which is useful if you need the key for React rendering (as mentioned in this answer about preserving _key during dereferencing).
The _key values you see (like "e4072b1d3618") are automatically generated by Sanity Studio. You typically don't construct these manually in GROQ queries - they're part of your stored document structure. If you're trying to create new reference arrays, you'd do that through mutations or the Studio interface, not GROQ queries (which are read-only).
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.