Package Exports
- @fourlights/strapi-plugin-deep-populate/package.json
- @fourlights/strapi-plugin-deep-populate/strapi-server
Readme
Strapi v5 Deep Populate Plugin
A Strapi v5 plugin that automatically populates all nested relations in a single request using populate: '*'.
It does not impose a limit on the level of nesting and can cache the populate object for improved performance.
Features
- Automatically resolves and populates all nested relations
- Supports all relation types including dynamic zones
- Handles circular references and edge cases
- Includes caching for improved performance
- Honors
populateCreatorFieldssetting
Installation
npm install @fourlights/strapi-plugin-deep-populateUsage
Enable deep population in your Strapi config:
// config/plugins.js
module.exports = ({ env }) => ({
'deep-populate': {
augmentPopulateStar: true, // default
cachePopulate: true // default
}
});Basic Usage
// Get fully populated document
const document = await strapi.documents("api.page.page").findOne({
documentId: 'xyz',
populate: '*'
});Advanced Usage
// Get populate object for custom usage
const { populate } = await strapi.plugin("deep-populate")
.service("populate")
.get({
documentId: 'xyz',
contentType: 'api::page.page',
omitEmpty: true // optional
});
const document = await strapi.documents('api::page.page').findOne({
documentId: 'xyz',
populate
});Caching
The plugin caches populate objects to improve performance. Cache can be disabled via the cachePopulate setting.
Creator Fields
The plugin automatically populates createdBy and updatedBy fields when populateCreatorFields is enabled in the content-type configuration.
How It Works
The plugin recursively:
- Traverses the content-type schema
- Retrieves documents with one-level deep populate
- Resolves all nested relations
- Returns a complete populate object
This process handles all relation types including dynamic zones and circular references.