Shopify + Sanity: Read about the investment and partnership –>

Advanced use cases for structure builder

Most often you return the structure definition as a function, but it's also possible to return a promise, or an observable. This allows you to build structure definitions from APIs, also in real-time. This section will walk you through some examples, as well as present some caveats.

Resolving structure from promises

Let's say you want to group projects in your portfolio by the dominant background color of the main image on that project. First you'll have to add a list item whose child is the list of colors derived from the project documents. Then, for each of these color list items, you will have to return a document list filtered by that color.

Resolving structure from observables

User specific structures

Was this article helpful?