Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 plans #70

Closed
ryanashcraft opened this issue Apr 25, 2017 · 10 comments
Closed

v2.0 plans #70

ryanashcraft opened this issue Apr 25, 2017 · 10 comments

Comments

@ryanashcraft
Copy link
Contributor

ryanashcraft commented Apr 25, 2017

Breaking Changes

Use latest entities state when the network request finishes for mutations

Motivation:

With redux-query 1.x, if you have simultaneous mutations that update the same entity, you could end up in with one mutation completely overwriting the changes of the other one. This is because the entities state for the update is captured before the network request starts, as opposed to when it finishes. Naturally, this has confused several people and just feels wrong.

Solution:

We'll make mutations behave more like requests when it comes to how the entities state is used when updating. transforms and updates will always be passed the latest entities state.

Breaking changes:

  • Logic depending on the previous behavior will break and need to be updated.
  • The returned value to the promise on mutation failures no longer include the "entities" field.
  • The "entities" field in mutation failure actions has been renamed "originalEntities".

Related issues:

Change "request" field in the actions and queries reducer

Motivation:

Currently there's a bug in redux-query 1.x where the middleware is calling abort on the request instance (i.e. the superagent instance), when the intention is that it should be called on the returned value from the network adapter.

Solution:

Provide a way for external code to reference both the adapter and the underlying instance. We may or may not want to rename "request" to better reflect its purpose.

Breaking changes:

  • Logic previously referencing the "request" field from the request/mutation start actions in order to get a reference to the underlying superagent instance need to be updated.

Related issues/PRs:

New Features

New rollback behavior and optional handler for reverting optimistic updates when mutations fail

Motivation:

With redux-query 1.x, mutation failures blindly revert the entire entities state. This shouldn't have much impact for apps that don't have many mutations going on simultaneously, but it's obviously a suboptimal/dangerous behavior.

Solution:

We now need to explicitly handle rollbacks per entity. By default we'll simply revert all optimistically-updated entities back to their previous value before the optimistic update. All entities without an optimistic update handler will be unaffected.

Additionally, we'll offer a custom hook in query configs to enable manual control of the rollback logic. This will enable you to safely support simultaneous mutations for the same entity when using optimistic update. It'll be important that apps consider providing a rollback handler whenever an entity is partially updated by multiple, possibly-simultaneous mutations.

Related issues:

Non-Breaking Bug Fixes and Improvements

@ryanashcraft
Copy link
Contributor Author

Most of these changes are near completion and are up on the 2.0 branch. I want to wrap this up and publish v2.0 as soon as possible. If you have feedback, please post here to discuss.

cc authors of related issues and PRs: @jnutter @acontreras89 @rogovdm @MrNice @bstro @nlf @ManThursday

@MrNice
Copy link
Contributor

MrNice commented Apr 25, 2017

Christmas in April! Thanks for all the work on this library - it's been good at supporting my use case since release, but these changes will give us a better error handling story and I'm excited about that.

Haven't updated in a while, probably since I added the first version of the multiple configs, so if we want a migration guide I'd be willing to help flesh that out.

I'd noticed the invalid warnings, nice to see them getting handled.

@bstro
Copy link

bstro commented Apr 26, 2017

This is great news! Thanks for the update.

@RohovDmytro
Copy link
Contributor

RohovDmytro commented Apr 26, 2017

Niiiice! 👍

What I want to see is some sort of «scope of the project»-thing. So the project would become officially and formally focused :)

For example, I'm not sure that caching layer fits perfectly — just because if fairly complex and has lot's of use cases and edge cases. Some of that stuff might be abstracted into redux-query-cache.

@ryanashcraft ryanashcraft mentioned this issue May 2, 2017
@ryanashcraft
Copy link
Contributor Author

Heads up – I've published 2.0.0-rc.1 to npm. If you use redux-query in your app, please try it out and let me know if you run into any issues. See https://github.com/amplitude/redux-query/blob/2.0/docs/transition-guides/v2.md for a transition guide.

@ryanashcraft
Copy link
Contributor Author

@rogovdm Short answer: I don't envision the scope of redux-query growing much more. The team feels that large, complicated features like query-batching would best be implemented in a separate, optional middleware module that can complement redux-query. I'm not sure exactly what you mean by "caching" here (would like to hear more about this), but likely would be best to have it live as a separate project.

@MrNice
Copy link
Contributor

MrNice commented May 9, 2017 via email

@ryanashcraft
Copy link
Contributor Author

@MrNice Let's continue discussing this in #1.

@ryanashcraft
Copy link
Contributor Author

2.0.0 has been published.

@ryanashcraft
Copy link
Contributor Author

See https://github.com/amplitude/redux-query/blob/master/docs/transition-guides/v2.md for a guide how to transition from 1.x to 2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants