Barelydead / strapi-plugin-populate-deep

A Strapi plugin that makes it easier to populate deep content structures
172 stars 39 forks source link

Forcing population of localisations #25

Closed pavelpetrcz closed 1 year ago

pavelpetrcz commented 1 year ago

Hi, Hello,

we use Strapi and your plugin in combination with plugin for internationalization - https://docs.strapi.io/developer-docs/latest/plugins/i18n.html

According to doc you should as for localizations in request to be send back in response. But we get the object "localizations" even if we do not ask for it.

I have strong suspicion that usage of your plugin caused that we have unwanted objects in response.

Could you add to your plugin check if localizations are requested before they are populated deeply and send back to the caller party please?

We use Strapi v4.3.4 and latest version of all plugins. If necessary, I will provide additional information later.

Thank you.

SannyNguyenHung commented 1 year ago

You will receive localizations because that is the purpose of this plugin.... A deep populate on the whole object. I have added 'localizations' to the global privateAttributes so that this property is no longer returned in combination with this plugin - This is only a workaround, it would be desirable if you could enable / disable it via a configuration and only if you perform a 'populate=deep'.

in ./config/api.js:

module.exports = {
  responses: {
    privateAttributes: ['localizations'],
  },
  .....
};
pavelpetrcz commented 1 year ago

You will receive localizations because that is the purpose of this plugin.... A deep populate on the whole object. I have added 'localizations' to the global privateAttributes so that this property is no longer returned in combination with this plugin - This is only a workaround, it would be desirable if you could enable / disable it via a configuration and only if you perform a 'populate=deep'.

in ./config/api.js:

module.exports = {
  responses: {
    privateAttributes: ['localizations'],
  },
  .....
};

Wonderful. I work in environment where it is not so easy to change implementation straight in the moment. We will ask our supporting company to implement that change. Hope it will be soon.