Closed rgant closed 7 years ago
Curses, I got the comments mixed up.
"authors relationship should have plural URLs." belongs to 365480e
"Update for tests. relationship links shouldn't exist if the jsonapi payload doesn't have a link." belongs to cb96719
@rgant Could you please just add a bit of a description here of the problem/use case that this solves?
I assume that what was missing was a way of knowing where the actual resource/object came from on the Json-Api side. this is useful so that we can post back to it etc... without having to assume anything about where it came from. Therefore GETS POSTS, PATCHS and DELETES, can be directed there.
Thanks for your help, appreciated as always!!
JSONAPI supports managing the relationships between objects directly: http://jsonapi.org/format/#crud-updating-relationships
This exposes that URL to the JavaScript code so we can use the URL for making updates:
var relationship = vm.item.$_JSONAPIMETA_.relationships.services.self;
There doesn't seem to be an obvious way to setup a "relationship" resource with js-data and js-data-jsonapi so I am still working on an optimal solution for that. But I know I will need the self relation URL to accomplish it.
Ok, so the effect of updating, adding or removing a foreign key value in js-data, for example should result in a POST, PATCH or DELETE to the relationship's self link would be the end goal
Sometimes yes. It depends on if we are just modifying the list, or adding new resources.
This patch will add self links to the relationships in the metadata. It also checks that the URLs are defined in the JSONAPI payload before adding to the metadata.
This will result in things like: