System Information
- Strapi Version: 4.1.8
- Node Version: 16.13.1
- NPM Version: 8.5.5
I’ve seen many posts on this issue, read the docs on new populate standard by quering. Tried many workarounds, no better results.
What I do get with new populate strategy is:
- I overriden find and findOne, just so i could insert some logs and see what is going on
- when populate=* or populate=fieldWanted query is passed, my console.log does show the fields on service level (api//services/.js), but it does not appear on controller level (api//controllers/.js).
- on service level, I did yet another test:
async find(...args) {
// Calling the default core controller
const { results, pagination } = await super.find(...args);
console.log('results:', results)
for(var i = 0; i < results.length; i++){
console.log('result'+i+':', results[i].users_permissions_user)
results[i].user = results[i].users_permissions_user
}
return { results, pagination };
},
Simply put, just changing the name of the field from users_permissions_user (the field I want) to simply user. This one (user) I receive!
- same occours with yet anoter type different than user_permissions_user. Created a foo content and linked to the one I’m fetching, same result: if it is on query, I can see the value on services level, but it is not served back, just if the mentioned trick is applied.
There is something going on between services and controllers that erases that specific relation field.
Creating a field with a relation, the issue is similar. I send post to api/my-content with something like
data:{
"value1": true,
"value2": false,
"users_permission_user": 2
}
receive result 200 but the relation is not created. I did not find out how the query is sent from controllers.create to services.create, but when it reaches services I can see the data, but the relational field is already erased.
Any thoughs?