Question about desk structure and refreshing when new documents are created.
The issue you're running into is a common gotcha with Structure Builder: when you fetch documents at configuration time using context.getClient().fetch(), that query runs once when the structure is built, not dynamically as content changes. The structure configuration is essentially static once it's created, so new documents won't appear until you refresh the entire Studio.
The solution is to use S.documentTypeList() or S.documentList() instead of manually fetching and mapping documents. These methods create dynamic lists that automatically refresh when documents are created, updated, or deleted.
Here's how to refactor your code:
S.list()
.title('Microcopy')
.items([
S.listItem()
.title('All Microcopy')
.child(
S.documentList()
.title('Microcopy')
.filter('_type == "microcopy"')
.menuItems([]) // Removes the "Create new" menu item
)
])Or even simpler, if you just want a filtered list without the top-level menu:
S.documentList()
.title('Microcopy')
.filter('_type == "microcopy"')
.menuItems([]) // This removes the top-level menu items
.canHandleIntent(() => false) // Optional: prevents this list from handling create intentsThe key differences:
S.documentList()creates a live-updating list that queries on-demand, not at build time.menuItems([])removes the "Create new" and menu buttons you mentioned wanting to hide- The list will automatically refresh when documents matching your filter are created or modified
If you need more complex filtering or grouping, you can still use GROQ filters with S.documentList() - they'll be evaluated dynamically. For example:
S.documentList()
.filter('_type == "microcopy" && defined(key)')
.params({}) // Add params here if using variables in your filterThe Structure Builder guide has more examples of creating filtered and grouped lists that update dynamically, including how to organize documents by date, status, or other properties.
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.