Open skqr opened 9 years ago
What steps need to be taken to implement PATCH? JSON-API removed PUT from their docs and I'd be interested in helping out as I'm working on a application with an Ember front end and Symfony backend and would like to use JSON-API and your bundle seems very much up to the task except for PATCH. Or could this be accomplished through the "ghost" functionality?
Support for the PATCH method is defined in the JSON-API spec.
This was not added initially because I actually prefer to make partial updates to my resources using PUT, also as defined by JSON-API.
Is this madness? Is this Sparta? Isn't that spitting in the eye of REST?
The answer is meh.
Actually, the most common implementation of PATCH is that of partial PUT updates in JSON-API - and this is wrong.
PATCH is supposed to take a patch document. Think of a
git diff
kind of thing.Will Durand, the author of REST APIs with Symfony 2: The Right Way, which used to be the best way until this bundle came along, expresses it beautifully in another post of his blog.
Great frameworks, such as Ruby on Rails, actually implement PATCH the wrong way.
JSON-API implements something similar to what the RFC for a JSON way of describing diffs between resource versions proposes.
This is much more like it. But it's still kind of hard for a client to implement, isn't it? This is why I prefer PUT so far. It's original intended use is not exactly a common case scenario, and I think being flexible within certain sane boundaries is constructive to the development of better and more useful standards.
That said, we still need PATCH to be JSON-API complete. So hack away.