JSONAPI Updating relationships


#1

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

#2

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


#3

@wecc Thank you.

Are there any plans to support it in the future?


#4

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


#5

Are there any news on this?


#6

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


#7

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