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

Value in store is not updated after mutation #356

Open
krstns opened this issue Mar 2, 2022 · 3 comments
Open

Value in store is not updated after mutation #356

krstns opened this issue Mar 2, 2022 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@krstns
Copy link

krstns commented Mar 2, 2022

According to docs, calling mutateUpdate* methods without passing additional parameters (like in the examples) should automatically update the data in the store without the need of a re-query.
I have strange results depending on where I run them.

Local machine:

  • calling mutate and then query with default caching will return the previous value.
  • calling mutate and then query with no-cache will return updated value
  • calling mutate and accessing object by using get will return object with old value

Stackblitz:

  • calling mutate and then query with default caching will return updated value.
  • calling mutate and then query with no-cache will return updated value
  • calling mutate and accessing object by using get will return object with old value

Here's my example:
https://stackblitz.com/edit/jasmine-in-angular-ioexpj?file=src%2Flib%2Fdata-manager.service.spec.ts

I would like to understand why the object is not updated in the store, as according to the docs it should be.
Also if someone could let me know why i have such a difference between stackblitz and my machine regarding the cached query it would be great.

@jesse-savary
Copy link
Member

Hey, taking a look into this.

@ryskin
Copy link

ryskin commented Jun 3, 2022

I have same issue

@krstns
Copy link
Author

krstns commented Jun 13, 2022

@ryskin Our solution (and I think the preferred official one) is to:

  • create a selector for the update with the updated fields
  • use the optimistic update to apply the update in the store

By using these two we are ok with our app. The update is immediate, when a query fails it's automatically reverted, the state of our store is the one we would expect to have.

Still, it's strange it does not work out of the box.

@jesse-savary jesse-savary self-assigned this Nov 6, 2022
@jesse-savary jesse-savary added the bug Something isn't working label Nov 6, 2022
@jesse-savary jesse-savary added this to Needs triage in Stability and Automated Testing via automation Nov 6, 2022
@jesse-savary jesse-savary added this to the v0.18.0 milestone Nov 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

3 participants