ember-jsonapi-resources
ember-jsonapi-resources copied to clipboard
Can not handle 204 no content for updating resources.
http://jsonapi.org/format/#crud-updating-responses-204
204 no content is a valid response, but it does not trigger any update on the Resource that was updated (since deserialize has nothing to do).
This is mostly an issue in https://github.com/pixelhandler/ember-fetchjax. Which decides that a 204 response should have it's own handler that returns an empty string. The regular success handler is not called, and the resolved promise shows no sign of a 204 response (an empty string as response is not a good way to check if this was a 204).
Which means there is no way to single out these requests and handle the updates/state on the just-updated-resource.
To fix this, I have sent in this PR on ember-fetchjax.
That PR will break EJR however. I have some EJR changes/patches coming up to (hopefully) completely fix relationship tracking which rely on that ember-fetchjax PR though.
@aars If I recall, I added the special "No Content" handler to accommodate behavior from JSONAPI::Resources gem in the Rails app I worked on while developing the library. Which should be based on this part of the spec:
- http://jsonapi.org/format/#crud-creating-responses-204
Note: If a
204response is received the client should consider the resource object sent in the request to be accepted by the server, as if the server had returned it back in a201response.
I guess I figured an empty String '', was better then an undefined or null response. But yeah sounds like we should revisit that.