JSONAPI Updating relationships

The JSONAPI documentation explains there are two ways to update relationships.

The first one “Updating a Resource’s Relationships” uses a PATCH request of the entire model and it’s relations. Like so:

PATCH /articles/1 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
  "type": "articles",
    "id": "1",
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "1" }
      }
    }
  }
}

This is how my Ember app works right out of the box.

I prefer using the second “Updating Relationships” where the relationship link is used:

PATCH /articles/1/relationships/author HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": { "type": "people", "id": "12" }
}

Does Ember Data 1.13.8 support this?

My current build uses:

  • Ember: 1.13.7
  • Ember Data: 1.13.8
  • jQuery: 1.11.3
1 Like

Unfortunately no, Ember Data does not currently support updating relationships using the relationship’s self link.

@wecc Thank you.

Are there any plans to support it in the future?

Yeah, I’m pretty sure we want to support that in the future.

Are there any news on this?

If you can migrate to Ember 2.x, this article might provide a solution:

Looking for the same. Specifically I want to be able to delete a relationship using the relationship URL and the delete method

1 Like