Relation Resolution - stringifiedStoriesCache prevents resolution of 1st level story relation if the story is also a 2nd level/nested relation #856
Labels
bug
Something isn't working
help wanted
[Contribution] Extra attention is needed
p2-edge-case
[Priority] Bugs with workarounds or limited impact.
PR welcome
[Contribution] Pull requests are welcome.
Dear storyblok client team,
it's a pleasure to interact with your libs and I want to thank you for your work.
And while doing so, I ran into a rather particular issue. A little deep-dive into the relations resolution mechanism yielded a funny issue.
Could be an edge-case scenario, however we ran into it and I think it is not so "edge-casy" after all.
Let's go:
stringifiedStoriesCache prevents resolution of 1st level story relation if the story is also a 2nd level/nested relation.
Expected Behavior
All found relations should be fully processed for relation resolution, regardless whether it is used as a nested/2nd level relation.
Current Behavior
If the relation is used as a 2nd level/nested relation in a 1st level relation, the 1st level relations won't be resolved because the stringifiedStoriesCache returns the API provided, non resolved item due to the first 2nd level relation resolution.
Important
It depends on the order of keys of
this.relatations
inresolveStories
which story gets processed and cached eagerly.Steps to Reproduce
Required data- and relation-structure:
The API correctly returns all relations:
Now when within
resolveStories
the code iterates over relations and passes every relation object intoiterateTree
to resolve ANDstory-3
is iterated earlier thanstory-4
, the resolution ofstory-4
as a relation ofstory-3
leads togetStoryReference
to store the non-resolved, API providedstory-4
in the stringifiedCache.Now
story-4
gets processed to resolve it's relations, butstory-432
's relations can't be resolved, because it is already in the stringifiedCache.I am happy to help out in any case.
Looking forward to a reply and best regards,
l
The text was updated successfully, but these errors were encountered: