Skip to content

faessler/strapi-plugin-populate-all

Repository files navigation

Strapi Plugin Populate All

Static Badge NPM Version GitHub Actions Workflow Status

A lightweight Strapi plugin that enables you to recursively populate all nested components, dynamic zones and relations in your REST API responses using a simple query parameter: ?populate=all.

Features

  • Use ?populate=all in your API requests to automatically and deeply populate all nested relations, components, and dynamic zones for any content type.
  • Fine-tune which relations are populated using plugin configuration.
  • The generated populate queries are cached, so repeated REST requests for the same model are faster.

Installation

All you need to do is install the plugin. Strapi should automatically detect and include it.

npm install strapi-plugin-populate-all

Usage

Just add ?populate=all to your REST API request, for example: GET /api/articles?populate=all This will return the article with all nested components, dynamic zones and relations fully populated, regardless of depth.

Configuration

The following configuration options can be added to your Strapi project's config/plugins.js or config/plugins.ts file.

Option Description Values
relations Controls which relations are populated when querying. - true: Populate all relations recursively (default)
- false: Do not populate any relations
- string[]: Populate only specific collection types by UID (e.g., ["api::article.article"])
cache Enables or disables the plugin’s in-memory cache for faster populate query generation. - true (default)
- false

Example usage:

module.exports = {
  "populate-all": {
    enabled: true,
    config: {
      cache: true,
      relations: true,
    },
  },
};

How it works

  • The plugin provides a global middleware that intercepts requests with ?populate=all and rewrites the query to trigger recursive population.
  • In the background, it builds a standard Strapi populate query as described in the Strapi documentation.
  • You can control which relations are included using the relations config option.
  • Inside the document API, you can set populate: '*' and populateAll: true to make it work

About

A lightweight plugin to recursively populate nested data in RESTful API requests

Topics

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •