Barelydead / strapi-plugin-populate-deep

A Strapi plugin that makes it easier to populate deep content structures
175 stars 43 forks source link

Self-Recursion Problem #8

Closed iocron closed 1 year ago

iocron commented 2 years ago

When 1:n, n:1, n:n relations are involved, the plugin populates everything self-recursively (we haven't tested other scenarios yet). For Example, a collection of cities and stations, when a city has multiple stations, and the station belongs to one city, then the plugin populates as deep as it can in both directions (default 5). Meaning the result (simplified) will look something similar to the example below. Instead the recursion should stop, once it tries to recurse into itself, meaning the recursion of a property / data should stop once it has already been recursed. I hope I am explaining it somewhat understandable. As far as I am aware, in real world examples there is (most of the time) no need to recurse / populate any further, once the final relation has been hit. +The depth functionality (default 5) might not be required anymore (or just as a hard fallback if everything goes wrong) and could be used optionally only if really needed. Maybe I am missing something, then let me know. Thanks for the great plugin, we are already using it, and we are only missing this one critical implementation to use it in production :) 👍

{
    "cities": [
        {
            "cityname": "London",
            "stations": [
                {
                    "stationname": "Townhall",
                    "cities": [
                        {
                            "cityname": "London",
                            "stations": [
                                // ...and so on
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
exotexot commented 2 years ago

I do have the same issue

Saurav404 commented 2 years ago

I was gonna report this issue as well, it just goes into a loop and populate the data again and again which increases the size of the fetched data.

Barelydead commented 2 years ago

Thanks for reporting! For the moment I won't look into this myself. If anyone wanna have a go at solving the issue im happy to review a PR and make a new release

ChrisKru97 commented 1 year ago

@Barelydead I created a fix for that, but I'm not sure if it works all the time. Nevertheless it helped at our project

36

AliRafay commented 1 year ago

@ChrisKru97 your changes works, updated this manually from node modules and it works smoothly, thanks

Barelydead commented 1 year ago

Fix merged to v3.0.0