How to populate relation field in repeatable component?

To populate relational fields and component fields of a collection type. We can simply use the Entity Service API like so:

strapi.entityService.findOne(
    "api::example.example", 
    id, 
    { populate: "*" }
);

However, this does not seem to populate relational fields nested inside of repeatable components.

For example, if I have the following collection type:

{
    name: string;
    relation: AnotherCollection;
    component: {
        name: string;
        relation: AnotherCollection2;
    }
}

and I try to query the collection type above using the Entity Service API code I have at the top of this post, it will only return this:

{
    name: string;
    relation: AnotherCollection;
    component: {
        name: string;
    }
}

so the relation inside of the component is not populated. How can I make the relational field inside of a component be populated when querying it?

Thanks for your time.

Ok I figured it out:

strapi.entityService.findOne(
    "api::example.example", 
    id, 
    { populate: { component: { populate: { relation: true } } } }
);

I didn’t realize I could access the populate field again for the component. Before I found the answer, I tried:
{ populate: { component: { relation: true } } }
which didn’t work.

populate=deep
This plugin allows for easier population of deep content structures using the rest API.
you just need to npm install strapi-plugin-populate-deep

1 Like

thanks man, but I am trying to access this in my api endpoint is there a way for that?

1 Like

Did you find solution?

@Reedham_pujara, @WardenCommander
Hmm, did you guys read the post? My second post includes the backend solution, and @rania included a front end solution (Which should work if you are trying to access it from the API endpoint @Reedham_pujara )

@blue Where do you put your solution? Is it in a file within the controller directory of the specified api? I see the documentation on how to populate, but I am still confused on where I am supposed to put the population configurations.