Loading associated records based on "linked" metadata

We at Instructure are trying to use JSON API standards in a new Ember application we are working on and we would like to use Ember Data. Our API returns associations in the “linked” key of the response. For example:

{
  "linked": {
    "authors": [
      {
        "id": "2",
        "name": "ericb@instructure.com",
        "avatar_url": null
      }
    ]
  },
  "meta": {},
  "course_templates": [
    {
      "id": "5",
      "estimated_time": 15,
      "passing_threshold": 80,
      "title": "Turkey Cornsquish",
      "is_published": true,
      "has_unpublished_changes": false,
      "default_days_until_due": 7,
      "next_section_due": "2014-07-26T06:00:00.000Z",
      "links": {
        "author": "2"
      }
    }
  ]
}

We have an Ember Data model called CourseTemplate and it belongs to an author. When I perform the find all function of the CourseTemplate model, I get the error: Error: No model was found for 'linked'.

Is this something that is supported in Ember Data? If not, does anyone have an example of how to handle this?

Ember-Data itself supports any API style, so long as you author the correct serializers and/or adapter. Ember-Data includes two adapters out of the box:

  • RESTAdapter - a fairly arbitrary format that is considered “simple”
  • ActiveModelAdapter - an adapter that consumes ActiveModelSerializers https://github.com/rails-api/active_model_serializers Note that although AMS once tracked JSON-API closely, it no longer does that

So, we can see that neither of these adapters seems to support the JSON-API spec. But you are not along in wanting an adapter for JSON-API, and @daliwali has started work on an adapter here:

tl;dr - Ember-Data supports data-modeling features like meta, links, or relationships. An adapter/serializer will support specific API semantics (such as serialization issues like how to specify links, or how to embed records).