Nested component definitions via Item Link returns only IDs
See original GitHub issueI’m not entirely sure if this is a bug or if this is as expected, but it seems like when I try to link objects beyond a certain level, only the IDs are returned.
In my case, I’m trying to link the following: Hero -> Card -> Stats
Hero is connected to the Card component via type: CommonFieldTypes.ItemLink
,
Card is connected to Stats via type: CommonFieldTypes.ContentList
,
and Stats are just objects with text fields.
Using this set up, I get the following returned in the api:
If I take the card definition out of the equation and link Hero directly with stats via type: CommonFieldTypes.ContentList
, I get what I would expect:
Note I left card in there so we can see the difference.
Is there a limitation to using ItemLink
, or is it a mistake on my end? Note that this is in disconnected mode. Here is a gist of some of the relevant code: https://gist.github.com/sowhatdoido/c1115c7adc5cc9efc0c7c1ee6b586a97
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
@bouncehead13 Fix for this issue is merged. I’m closing this one.
@kamsar. If you flip the usage array so that it resolves from the bottom up, it will resolve the references in the children before cloning to the parent. You can fix it in one of two ways:
In
expandReferencedContent.js
in thesitecore-jss-manifest
package, you can reverse the array before traversing itIt would be more performant if you guys updated
createIdMapping.js
to useunshift
instead ofpush
, which will result in a reversed array during creation.I don’t know if there are any unforeseen side effects for this change as we don’t have access to any tests, but making that change in my local node_modules seemed to have resolved the problem: