Expand nested properties in Content Delivery API f...
# help-with-umbraco
k
Hello, we are using Umbraco 13 for building a Headless site against NextJs , for the pages, we defined a couple of page placeholders “Block List” properties that hosts the page components, within those components there are some components that play as layout components - container, row col splits.. etc, so those components have their own block list fields. As we are using Content Delivery API V2 To get those block list fields we use
expand=properties[$all[properties[$all]]
, but this expand fields for two levels, so we added and extra level to support blocks on third level, but this approach is not maintainable as we cannot predict all the scenarios and the block list fields could be presented in any level, Using V1
expand= all
works fine as it expands all props all the way. So is there a way to get this to work dynamically, for example a configuration to define couple of field aliases to expand by default or something like that. Thanks!
I see in the
RequestContextOutputExpansionStrategyV2.cs
that
forceExpandProperties
is set to
true
for
MapElementProperties
, so is this by design can w e override it? https://github.com/umbraco/Umbraco-CMS/blob/2736a513a3dd0a29aeac61ace614ff2effdf7135/src/Umbraco.Cms.Api.Delivery/Rendering/RequestContextOutputExpansionStrategyV2.cs#L57
r
I have a similar issue. Did you resolve it or hear from the Umbraco team through other channels?
j
I believe
expand=all
only expanded the first level anyway. With the V2 syntax, you can expand as many levels as you wish, although that is not advisable as that could bottleneck your whole system. Blocks are the exception, where if the delivery api encounters a block in the output it will be auto-expanded, so you might have seen on V1 that is was your blocks that auto-expanded in the first level and that could have looked like "infinite expanding". > I see in the RequestContextOutputExpansionStrategyV2.cs that forceExpandProperties is set to true for MapElementProperties, so is this by design can w e override it? No, not by design. You would have to replace a lot of code to do that. Can I ask for your use-case to wanting to expand a seemingly infinite level of content? If you know how many levels of containers, rows, columns you have, you can expand that, I suppose?
37 Views