Json-api links and relationship links in ember data

Hi All, I am not able to see any reference on how to consume the data object links and self and related links of JSON-api spec in ember data. Any pointers or references will be greatly helpfull.

Thanks, kavitha

Do you need access to those links for a special reason, or do you just want to access the data from those links? I’m going to assume the latter. If you just want to access the data, Ember Data will use those links internally to fetch the related data so that you won’t have to manually access those URLs and make requests to them. You just have to declare the relationships on your model. If I did assume correctly, maybe this will help. I wrote a blog post on this using the RESTSerializer format, but the same technique can be applied to JSON:API. http://thejsguy.com/2016/02/21/handling-nested-resources-in-ember-data.html

Unfortunately “related” links are the only ones used by ember-data. If your api only returns links to relationships rather than the embedded ids and types, then ember will use the “related” link to grab related data. This has some downsides, mainly that the data might already be loaded, it’s just there was now relationships to create the link between entities.

There’s an RFC though that would improve this and allow loading relationship data from relationship self links: https://github.com/emberjs/rfcs/pull/160