diff --git a/packages/core/content-manager/server/services/entity-manager.js b/packages/core/content-manager/server/services/entity-manager.js index 059d4f77868..227781646f0 100644 --- a/packages/core/content-manager/server/services/entity-manager.js +++ b/packages/core/content-manager/server/services/entity-manager.js @@ -1,6 +1,6 @@ 'use strict'; -const { assoc, has, prop, omit } = require('lodash/fp'); +const { assoc, has, prop, omit, merge } = require('lodash/fp'); const strapiUtils = require('@strapi/utils'); const { ApplicationError } = require('@strapi/utils').errors; @@ -40,15 +40,11 @@ const findCreatorRoles = entity => { }; // TODO: define when we use this one vs basic populate -const getDeepPopulate = (uid, populate, depth = 0) => { +const getDeepPopulate = (uid, populate) => { if (populate) { return populate; } - if (depth > 2) { - return {}; - } - const { attributes } = strapi.getModel(uid); return Object.keys(attributes).reduce((populateAcc, attributeName) => { @@ -60,7 +56,7 @@ const getDeepPopulate = (uid, populate, depth = 0) => { if (attribute.type === 'component') { populateAcc[attributeName] = { - populate: getDeepPopulate(attribute.component, null, depth + 1), + populate: getDeepPopulate(attribute.component, null), }; } @@ -71,7 +67,7 @@ const getDeepPopulate = (uid, populate, depth = 0) => { if (attribute.type === 'dynamiczone') { populateAcc[attributeName] = { populate: (attribute.components || []).reduce((acc, componentUID) => { - return Object.assign(acc, getDeepPopulate(componentUID, null, depth + 1)); + return merge(acc, getDeepPopulate(componentUID, null)); }, {}), }; }