- Strapi Version: 3.6.2
- Operating System: Ubuntu
- Database: MySQL
- Node Version: 12.18.2
- NPM Version: 7.6.1
- Yarn Version: 1.22.10
This is more of a concept question. We set up a custom collection for pages and have the internationalization all working in our client app. Multiple languages can have the same path, so our client app requests by path and then uses the matching language page by selecting either the main page or a matching page in the localizations array of pages based on the locale.
We have a need to swap out some placeholders with text on the pages on the server-side, so we were thinking we would add a custom controller in our pages plugin to do this. The first question is, is this the best place for this type of logic?
In this custom controller when we look at the localizations array it only contains the id and the locale name for each of the localized pages. So my main question is whether there is a way to hydrate that object so that we have all of the page attributes, in particular, the content attribute so that we can swap out the placeholders before it is returned to the client app?
My understanding is that all the data is in the GraphQL response because GraphQL is hydrating the response, but that seems too late for us to hook into. It seems like our logic belongs in the model or the controller.
I think with a little direction we can figure out the code, but it’s just not clear how best to approach this localization issue where the localized data is in the same table. Any guidance would be greatly appreciated!