Getting relationships on a User does not return the normal data: attributes: object structure

Ran into this today, and wondering if there is a nicer way to do what I want.

I was doing a REST API call to retrieve Users, and populating a relationship that I have on my Users. First thing I noticed was that the Users collection itself did not return the normal strapi 4 data:{ id:123, attributes: {}} structure that everything else does. I have read that this is by design, and that User collections return a more flattened object.

Ok, that is fine, however it looks like any relationship you populate on your Users query also gets flattened. So I have a “Projects” collection type. When I query that collection normally I get the data/attributes object, but when I populate the relationship on a Users query, the Projects object is flattened down to not use the data/attributes structure.

This makes it hard to build components when depending on how I am querying the data, the format will be different. I have made a utility that normalizes the data, so it is working right now, but is there a better way to normalize what comes back in User queries? A way to make relationship fields on a User not get flattened?

This topic has been created from a Discord post (1255616625810604123) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord