
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeGood news - you're on the right track! You can absolutely reference parsedSlug from the parent scope using the parent operator (^), but you need to adjust your syntax slightly.
In your query, you're already correctly using ^._id to reference the parent's _id field. The same pattern works for your custom parsedSlug field. Here's the corrected version:
*[_type == 'devCategory'] {
_id,
"level": 0,
"title": coalesce(title[$lang], title.en),
"parsedSlug": slug.current,
"children": *[parent._ref == ^._id] {
_id,
"level": 1,
"slug": ^.parsedSlug + "/", // This will work!
"title": coalesce(title[$lang], title.en),
}
}The key point is that ^.parsedSlug refers to the computed field from the parent document's projection (the outer query). Since you're defining "parsedSlug": slug.current in the parent scope, you can access it in the nested query with ^.parsedSlug.
The parent operator (^) lets you traverse up one level in scope. If you needed to go up multiple levels, you could chain them like ^.^.fieldName, but in your case, one caret is perfect since you're only one level deep.
One thing to be aware of: if you're using an API version before 2021-03-25, there was a bug with the parent operator that could cause unexpected behavior. If you run into issues, make sure you're on a recent API version.
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