tl;dr : Would it be useful to be able to get chained relationships (relationships of relationship) in top-level
I am trying to understand how the
relationships object works.
I have a model with chained relations that I want to fetch. I want to present 2 use cases :
User hasOne Profile Profile hasOne Region Region hasOne Country Country hasOne Continent
If I want to get the related Continent, I need to request my user, including
profile.region.country.continent. The top-level relationship object would contain the Profile ID, I would need to look up the Profile in the Includes array to get the Region ID, and again the Region to get the CountryID and again the Country to get the ContinentID.
It is redundant and a lot of post-processing (look up in the
include array), and my backend feed itself from a RDB which is not fully used
Profile has one Country as originCountry has many Country as visitedCountries has many Profile as friends
In this situation, what I get from this post is, if I want to get my Origin country, the countries I visited and all the countries my friends visited, I should include :
Such a request would give me a top-level relationships object with the
visitedCountries of mine but only the ids of my friends, and their countries in include. Here, there is big chances that the countries I will get will be redundant and, the include system allows me to get less data through HTTP.
The all-flaten representation is useful, but it would be nice to be able to reach the relationships of a relationship directly in the top-level object, preventing unnecessary post-processing to reconstruct data that is represented in a relation-wise fashion on server-side. Wouldn’t it?
Thank you for reading.