Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module.exports = ({ env }) => ({
'strapi-plugin-populate-deep': {
config: {
defaultDepth: 3, // Default is 5
excludeLocalizations: true // do not include localizations for other languages in response if using i18n plugin
}
},
});
Expand Down
7 changes: 6 additions & 1 deletion server/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ module.exports = ({ strapi }) => {
if (event.action === 'beforeFindMany' || event.action === 'beforeFindOne') {
const populate = event.params?.populate;
const defaultDepth = strapi.plugin('strapi-plugin-populate-deep')?.config('defaultDepth') || 5
const excludeLocalizations = strapi.plugin('strapi-plugin-populate-deep')?.config('excludeLocalizations') || false

if (populate && populate[0] === 'deep') {
const depth = populate[1] ?? defaultDepth
const modelObject = getFullPopulateObject(event.model.uid, depth, []);
const ignored = []
if (excludeLocalizations) {
ignored.push('localizations')
}
const modelObject = getFullPopulateObject(event.model.uid, depth, ignored);
event.params.populate = modelObject.populate
}
}
Expand Down