Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions server/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const getModelPopulationAttributes = (model) => {

const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
const skipCreatorFields = strapi
.plugin("strapi-plugin-populate-deep")
?.config("skipCreatorFields");
.plugin("strapi-plugin-populate-deep")
?.config("skipCreatorFields");

if (maxDepth <= 1) {
return true;
Expand All @@ -26,7 +26,7 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
if (ignore && !ignore.includes(model.collectionName))
ignore.push(model.collectionName);
for (const [key, value] of Object.entries(
getModelPopulationAttributes(model)
getModelPopulationAttributes(model)
)) {
if (ignore?.includes(key)) continue;
if (value) {
Expand All @@ -35,14 +35,14 @@ const getFullPopulateObject = (modelUid, maxDepth = 20, ignore) => {
} else if (value.type === "dynamiczone") {
const dynamicPopulate = value.components.reduce((prev, cur) => {
const curPopulate = getFullPopulateObject(cur, maxDepth - 1);
return curPopulate === true ? prev : merge(prev, curPopulate);
return merge(prev, {[cur]: curPopulate});
}, {});
populate[key] = isEmpty(dynamicPopulate) ? true : dynamicPopulate;
populate[key] = isEmpty(dynamicPopulate) ? true : { on: dynamicPopulate };
} else if (value.type === "relation") {
const relationPopulate = getFullPopulateObject(
value.target,
key === "localizations" && maxDepth > 2 ? 1 : maxDepth - 1,
ignore
value.target,
key === "localizations" && maxDepth > 2 ? 1 : maxDepth - 1,
ignore
);
if (relationPopulate) {
populate[key] = relationPopulate;
Expand Down