strapi-plugin-populate-all 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,3 +49,4 @@ module.exports = {
49
49
  - The plugin provides a global middleware that intercepts requests with `?populate=all` and rewrites the query to trigger recursive population.
50
50
  - In the background, it builds a standard Strapi populate query as described in the [Strapi documentation](https://docs.strapi.io/cms/api/rest/populate-select).
51
51
  - You can control which relations are included using the relations config option.
52
+ - Inside the document API, you can set `populate: '*'` and `recursive: true` to make it work
@@ -82,8 +82,8 @@ const getPopulateQuery = (modelUid, parentsModelUids = []) => {
82
82
  const bootstrap = ({ strapi: strapi2 }) => {
83
83
  strapi2.db.lifecycles.subscribe((event) => {
84
84
  try {
85
- if (event.params?.recursive === "true") {
86
- if (event.action === "beforeFindMany" || event.action === "beforeFindOne") {
85
+ if (event.action === "beforeFindMany" || event.action === "beforeFindOne") {
86
+ if (event.params?.populateAll) {
87
87
  strapi2.log.debug(
88
88
  `[populate-all] recursively populate ${event.model.uid}`
89
89
  );
@@ -135,7 +135,7 @@ const middlewares = {
135
135
  populateAll: async (ctx, next) => {
136
136
  if (ctx.query.populate === "all") {
137
137
  ctx.query.populate = void 0;
138
- ctx.query.recursive = "true";
138
+ ctx.query.populateAll = true;
139
139
  }
140
140
  await next();
141
141
  }
@@ -81,8 +81,8 @@ const getPopulateQuery = (modelUid, parentsModelUids = []) => {
81
81
  const bootstrap = ({ strapi: strapi2 }) => {
82
82
  strapi2.db.lifecycles.subscribe((event) => {
83
83
  try {
84
- if (event.params?.recursive === "true") {
85
- if (event.action === "beforeFindMany" || event.action === "beforeFindOne") {
84
+ if (event.action === "beforeFindMany" || event.action === "beforeFindOne") {
85
+ if (event.params?.populateAll) {
86
86
  strapi2.log.debug(
87
87
  `[populate-all] recursively populate ${event.model.uid}`
88
88
  );
@@ -134,7 +134,7 @@ const middlewares = {
134
134
  populateAll: async (ctx, next) => {
135
135
  if (ctx.query.populate === "all") {
136
136
  ctx.query.populate = void 0;
137
- ctx.query.recursive = "true";
137
+ ctx.query.populateAll = true;
138
138
  }
139
139
  await next();
140
140
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.2",
2
+ "version": "1.2.3",
3
3
  "name": "strapi-plugin-populate-all",
4
4
  "description": "A lightweight plugin to recursively populate nested data in RESTful API requests",
5
5
  "keywords": [],