Proposal: a "populate" parameter for API requests
When fetching a single item or a list of items from the API, a populate
query parameter would specify the fields of the response that should be converted from ids to full objects.
For example when fetching a list of collections, the client would add populate=owners,teams
and those fields would be populated with the full objects.
The response needs to be converted back to invididual objects (depopulated) in the client, before being added to the redux store.
This is a generalisation of the current ownersWithUsername
method that currently converts owner ids to user objects, but is applied inconsistently across API responses (see pubsweet-server#46).
The alternative is for the client to fetch each object from the API individually, which is possible but can lead to a lot of queries for a complex view such as a dashboard.
Implementing GraphQL would be another solution, as populating data for a view is one of the core problems that it solves.