
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand what you're trying to achieve! You want parent documents to automatically have their reference arrays populated when child documents are created, while still allowing editors to manually sort those references. Let me walk through your options:
Unfortunately, there isn't a built-in way to automatically populate a reference array in a parent document when a child is created. References in Sanity work in one direction—you need to explicitly add them where they're defined in your schema.
However, you have several approaches to solve this:
Instead of maintaining a reference array in the parent document, you can query for children on your frontend and let editors control the sort order through a plugin.
How it works:
orderRank field that the plugin managesExample schema for child document:
{
name: 'child',
type: 'document',
fields: [
{
name: 'parent',
type: 'reference',
to: [{type: 'parent'}]
},
// orderRank is managed by the orderable-document-list plugin
]
}Example GROQ query:
*[_type == "parent" && _id == $parentId][0] {
...,
"children": *[_type == "child" && references(^._id)] | order(orderRank)
}Benefits:
You could use Sanity Functions to automatically update parent documents when children are created. Functions are serverless compute that run on Sanity's infrastructure and can react to document events.
How it would work:
Important considerations:
You could build a custom input component that shows all potential children and lets editors select/sort them in one interface. This would still require manual selection but could make the UX much smoother than adding references one by one.
Go with Option 1 (query-based approach with the orderable-document-list plugin). It's the simplest, most maintainable solution that still gives your editors full control over sorting. The "auto-population" happens naturally through the query—you're just flipping the relationship direction so children point to parents instead of parents maintaining arrays of children.
This is a common pattern in Sanity and works well because references are bidirectional when queried, even though they only appear in the Studio UI where they're defined. Your editors get a clean drag-and-drop sorting interface, and you avoid the complexity of keeping reference arrays in sync.
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