How to deeply populate (sub)components inside dynamic zone

System Information
  • Strapi Version: 4.0.3
  • Operating System: Linux
  • Node Version: v12.22.9

Hi all,

I like strapi very much.
It is highly flexible in using components inside components inside dynamic zones. But fetching this content seems to be hard…

I have a dynamic zone “Content”, that contains a lot of components.
But how can i pull all components with all information out of the api?

My content:

I have read the documentation about the populate parameter, but I need to deeply populate all components in the dynamic zone. Preferable without having to name everything I want inside the populate argument.

Is there a way that I can specify the number of population levels? I’ve read somewhere that this is 2 by default.

Or is there a way that I can pull out (in a separate request) all populated components found in dynamic zone “Content”?

Regards,
Bart.

I am struggling with this as well. Its so frustrating! For me everything is working until you have a component with components and then it doesn’t populate. Have you gotten it to work with nested components yet even if its manually?

I have an open github issue currently Deep Querying components in Dynamic Zone not working correctly · Issue #290 · gatsby-uc/gatsby-source-strapi · GitHub

Nope, still looking for a solution…

Maybe we will have luck with the gatsby conf happening. I am attending if you are not I will feedback here for you If I make any headway :slight_smile:

We don’t use gatsby (yet).
We (webleads) are looking to create a “hybrideCMS” with Strapi and ForkCMS…

this worked for me
?populate=*

It does not work with dynamic zones and (sub)components.

Look at this example:

The compoment “blocks.image-left” looks like this:
Title (Text)
SubTitle (Text)
Body (Rich text)
Image (Media)
Link (Component)
Text (Text)
Hyperlink (Text)
Hint (Text)

In the api result you see that the component “blocks.image-left” only has the id, Title, SubTitle and Body field.

1 Like

Hey Bart, if you’re still looking for a solution check-out this thread.

Looks like it worked for many people by editing strapi’s controller

Ah, will check that out, thx for pointing me to it :wink:

Same issue here :frowning:

Strapi needs a super simple way to populate everything all the way down multiple levels. May I suggest: populate=everything_dammit__yes_i_accept_the_consequences_of_my_actions

6 Likes

I have a dynamic zone “sections”, i use qs (npm i qs)

const queryPages = qs.stringify(
  {
    populate: {
      sections: {
        populate: "*",
      },
    },
  },
  {
    encodeValuesOnly: true, // prettify URL
  }
);

result

populate[sections][populate]=%2A

i already populate all the component inside dynamic zones, but do anyone know how to return only url for the media, dont want the other attributes because the response will be so long