Second level of nested relationship not available in response

I am having these types with the following relationships:

  • Page A (single type) which has many toolboxes
  • Toolboxes (collection type) which has many tools
  • Tool (collection type) which belongs to one Toolbox

/page-A response:

{
    //...
    "toolboxes": [
        {
            "id": 1,
            "name": "resources",
            //...
            // expecting a tools field at some point, but there are none!
        },
        {
            "id": 2,
            // ...
        },
        {
            "id": 3,
            // ...
        }
    ]
   // ...
}

/toolboxes response:

[
    {
        "id": 1,
        "tools": [
            {
                "id": 1,
                // ...               
            },
            {
                "id": 2,
                // ...
            },
            {
                "id": 3,
                // ...
            }
        ]
    },
    {
        "id": 2,
        "tools": [...]
    },
    // ...
]

When querying the Page A (GET /page-a), I am having a toolboxes array field in the response containing all the toolboxes defined in the relationship. But each toolbox object from this array does not contain a tools array in turn.

It looks like the REST API is limiting the relationships nesting in the response. So my questions are:

  • Is that by design (if so, I think it worth mentioning it in the doc at some point)?
  • Should I perform an extra query to fetch the missing nesting level of relationship?

This question is somehow related to this post I guess.

System Information
  • Strapi Version: 3.3.3
  • Operating System: Windows 10
  • Database: mysql
  • Node Version: 14
  • NPM Version: 6
  • Yarn Version:

Yes by default we only populate one level deep

You can customize the service to increase the level of population, see this answer: Simple nested array issue - #4 by DMehaffy

2 Likes