Skip to content

RFC: JSON Patch support for Ember Data#5

Closed
pixelhandler wants to merge 1 commit intoemberjs:masterfrom
pixelhandler:json-patch-support-for-ember-data
Closed

RFC: JSON Patch support for Ember Data#5
pixelhandler wants to merge 1 commit intoemberjs:masterfrom
pixelhandler:json-patch-support-for-ember-data

Conversation

@pixelhandler
Copy link

Rendered

@machty suggested that I add the proposal I posted on the discuss forum to this repo, see: http://discuss.emberjs.com/t/json-patch-support-for-ember-data/6078 ( json patch support rfc )

"Extend Ember Data Model prototypes to have individual 'updatable' properties. Model instances can receive patch operations in response to updating or deleting records (PUT or DELETE requests) by pushing partial changes into the store (DS.Store#update). Create mixins for Model, Adapter & Serializer prototypes which support using a JSON Patch rfc6902 format in payloads sent as responses in order to apply partial updates."

@pixelhandler pixelhandler changed the title [RFC] JSON Patch support for Ember Data RFC JSON Patch support for Ember Data Sep 3, 2014
@pixelhandler pixelhandler changed the title RFC JSON Patch support for Ember Data RFC: JSON Patch support for Ember Data Sep 3, 2014
@brancusi
Copy link

+1

1 similar comment
@DougPuchalski
Copy link

+1

@wycats wycats added the T-ember-data RFCs that impact the ember-data library label Oct 1, 2014
@michiel
Copy link

michiel commented Oct 25, 2014

+1

6 similar comments
@JockeTF
Copy link

JockeTF commented Nov 6, 2014

+1

@altrim
Copy link

altrim commented Nov 6, 2014

+1

@tagisen
Copy link

tagisen commented Nov 21, 2014

+1

@jheth
Copy link

jheth commented Nov 21, 2014

+1

@MiguelMadero
Copy link

👍

@ablanco
Copy link

ablanco commented Dec 3, 2014

+1

@workmanw
Copy link

workmanw commented Dec 3, 2014

OMG. +1.

@mhretab
Copy link

mhretab commented Jan 9, 2015

+1

3 similar comments
@dustinfarris
Copy link

+1

@jeffreylouden
Copy link

+1

@goto-bus-stop
Copy link

👍

@timini
Copy link

timini commented Feb 5, 2015

Want :)

@egaba
Copy link

egaba commented Feb 10, 2015

+1

1 similar comment
@joebartels
Copy link

👍

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, models shouldn't know about data exchange mechanisms with the server. We'd entangle models with adapters with servers, which would lead to highly coupled code.

In my opinion, we should add a new method in the store such as bulkSave that would trigger yet another method in the adapter, patch. Adapters without this method mean they don't support this and regular createRecord / updateRecord would be used.

The adapter's patch method would receive a special object called DirtyRecords (or along those lines), which would yield an array of all records that are pending save in the store. Adapter would craft a JSON Patch request based on that object.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kurko I understand your concern. My intention is that a model can trigger an event on the store service such as attributeChanged then the service/adapter can do what it wants, e.g. perhaps call a patch method. This is an example of one way that I've implemented this behavior to patch a change in as close to real time as possible - https://github.com/pixelhandler/ember-jsonapi-resources/blob/master/README.md#resource-services and here - https://github.com/pixelhandler/ember-jsonapi-resources/wiki/Services#collaborators

I really enjoyed this behavior when I tried out ember-orbit with json-patch. So I've borrowed that behavior for my own persistence needs as well.

@jeremytm
Copy link

jeremytm commented May 5, 2015

+1

4 similar comments
@archit
Copy link

archit commented May 15, 2015

+1

@ryanlitalien
Copy link

+1

@kalebdf
Copy link

kalebdf commented Jun 9, 2015

+1

@pybt
Copy link

pybt commented Jun 24, 2015

+1

@coen-hyde
Copy link

Yes please!

@kurko
Copy link

kurko commented Jun 28, 2015

All of these +1 don't add anything. Your interaction will be much more effective if you, for instance, reply to my comment above about coupling models with servers.

@tikotzky
Copy link

@kurko this chrome extension is a godsend... Github +1s
though you still do get the email notifications...

@jeremytm
Copy link

@kurko I'm not sure I understand why. Also, there is a button 'Add a line note' to your comment. Is this what you mean? Is it better to add '+1' there instead?

@kurko
Copy link

kurko commented Jun 29, 2015

@jeremytm I'm suggesting you to elaborate on why you agree or disagree with #5 (comment), which looks like a blocker IMO.

@jeremytm
Copy link

I think like myself, many us here just want to show support for adding PATCH capabilities into Ember Data - assuming that the brilliant minds behind it will know how to work through any obstacles and blocks - and land on the best implementation.

Any developer knows the features that are requested most are the ones that receive attention, so that's the goal here from these +1's I think.

What's the next step? (I do agree with your statement btw, that models should only know what they need to know and nothing more). Does someone start a new thread with an evolved implementation suggestion? Then we all jump over there with our +1's?

@pixelhandler
Copy link
Author

@jeremytm this is the 5th PR on this RFC repo (this weekend I created the 69th PR), and has not had any attention/response from the Ember Data team. Not so much as a "no that's not a good idea" or any response with an alternative solution.

I expect that I will just continue to develop my own custom solutions for data persistence. Here is my story and path forward for my data persistence needs: http://pixelhandler.com/posts/my-battle-with-data-persistence-in-ember-apps and the repo I am now using for JSON API - https://github.com/pixelhandler/ember-jsonapi-resources I may implement JSON PATCH on that project once my backend is ready for it. I ran with JSON Patch on personal project for about a year and really enjoyed it. For me, the JSON API spec is really the main driver for a solid client-server solution for Ember apps. Ember Data is also using the format for JSON API as well. The Ember Orbit project did have JSON Patch support but I'm not sure if that will continue.

About a year ago, I spoke with one of the Ember Data team members and doubts about JSON Patch were raised concerning enforcement of an order of patch operations. (I think that the Orbit.js project did address that concern internally.) In an application with lots of read/write activity timestamps may be necessary to enforce the order of operations when processing a batch of operations. I really like the idea of using the test operation to validate that each current operation is valid on the server side.

@kurko
Copy link

kurko commented Jun 30, 2015

@wecc @igorT any chance this could get some eyes? I think this moves in the right direction.

@dgeb
Copy link
Member

dgeb commented Jun 30, 2015

@pixelhandler - let me address the questions you raised about Orbit and Ember-Orbit.

Orbit internally uses JSON Patch operations to transform sources and emit notifications that sources have transformed. This is still the case and I don't expect this to change.

Furthermore, Orbit has a Source that communicates via JSON Patch operations with a server: the JSONAPIPatchSource. This source communicates using the experimental JSON Patch Extension to the JSON API spec. I have placed development of the JSONAPIPatchSource on hold temporarily until we settle the extension support details in JSON API. We have targeted this feature for JSON API 1.1, which will be released in beta on September 30th.

So to recap, Orbit is fully committed to continuing to support JSON Patch operations internally and will also support the final form of the JSON Patch extension that lands in JSON API.

Now that we've finalized JSON API 1.0, I'm devoting almost all my OSS time to stabilizing and refining Orbit and Ember-Orbit. It would be a massive duplication of effort to enable the same internal and external communication mechanisms in Ember Data. I'm open for discussions with the Ember Data team regarding collaboration options between our projects.

@SeyZ
Copy link

SeyZ commented Jul 3, 2015

👍 +1

@jeremytm
Copy link

JSON API 1.0 requires PATCH requests for updates, and it looks like in Ember data 1.13, using the JSONAPIAdapter, it's sending out PATCH requests for all updates by default - just for anyone else who ends up here, and has the ability to use JSON API 1.0 for their backend.

@pixelhandler
Copy link
Author

Nice discussion, thanks everyone. Closing this, it doesn't need to be a thing in Ember Data, cheers.

chancancode pushed a commit that referenced this pull request Oct 27, 2017
Clarify taking addresses of globals in globals
rwjblue pushed a commit that referenced this pull request Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Response T-ember-data RFCs that impact the ember-data library

Projects

None yet

Development

Successfully merging this pull request may close these issues.