Users/me is not returning relation field of type 'belong to many'?

I have created a relation between user and a collection type named Orders which is of “belong to many” type. And when i try to query users/me for related orders IDs then it returns nothing. How do i fix it?

![2|690x347]

We disable all relation population in /users/me unless you extend the users-permissions plugin, specifically this service:

This is done for performance reasons, you can see in that code sample that only role exists in the population array, just add the field name of the relation field you wish to populate. If you need to go deeper you can do something like:

['role', 'orders', 'orders.someNestedRelation']

See: Strapi plugins - Strapi Developer Documentation to see how to extend a plugin.

I included the related collection to the user/me request but I’m not getting back the component related fields. Any ideas how to include that data?

i.e. I have the taxId and personalDocument on the response but I don’t get the address

Hi,

I tried your code suggestion by editing the file ./node_modules/@strapi/plugin-users-permissions/server/services/user.js. It works fine !

But I think it’s not a good idea in the long term. The package update will remove this modification.

For example, I try to add “./src/extensions/users-permissions/server/services/user.js” without good result.

My question is, how can I override/extend the file without modify the original file ?

Thanks in advance for your response.

Normally you should use patch-package to generate a patch file that will automatically update the node_modules for you.

But anyway this issue will be fixed in: Address multiple users & permissions issues by alexandrebodin · Pull Request #13435 · strapi/strapi · GitHub

You can find my patch file for this PR here (based on v4.1.12): Address multiple users & permissions issues by alexandrebodin · Pull Request #13435 · strapi/strapi · GitHub from where I was testing the fix. It will auto populate the role field now if the user has access to find roles