As Ember data 1.13 supports now JSON API 1.0 I’m wondering if it will be possible to take advantage of the Compound Documents defined by the JSON API to reduce the number of HTTP requests.
I’m still a very beginner regarding Ember data but I’d like to know if a JSON API request like
as shown here can be somehow modeled with Ember data. With the new Ember data 1.13 naively I’d do something like the following (sorry if the code is wrong but I hope you get what I mean)
// Issue HTTP request to fetch the first page of articles let articles = this.store.findAll('articles'); articles.then(() -> let article = articles.objectsAt(0); // Will cause a second HTTP request to fetch the related author? article.get('author'); )
… or would I need to use
store.query('articles', query) and define within the query the includes? Honestly so far I’ve no clue how to tell the store beforehand that it shall include the related author when fetching an article.
Also in order to reduce traffic it’d be awesome if you could declare that you’re only interested in a sub set of properties from a resource instead of all (see sparse fieldsets of JSON API). Similar to the example above I could be interested only in the title of the articles and the name of the related author. Such a request could be expressed with JSON API like:
Is there any way to declare that you’re interested only in a sub set of properties so that (if supported by the Adapter) the request gets optimized?
Sorry in case I’m asking nonsense here.
Thanks a lot!