-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@ngrx/data optimisticUpdate does not work with custom selectId #2059
Comments
@marcinmajkowski, yeah, I think you are right, should use |
Thanks @marcinmajkowski, it's yours to fix if you want it. |
I'm heaving a similar issue with a call to mustBeUpdates() Error: Hero EntityAction guard for "[Hero] @ngrx/data/entity-cache/save-entities": payload , item 1, has a missing or invalid entity key (id) Even though the type checker yields no errors. There is a stackblitz to reproduce (it's based on @marcinmajkowski's stackblitz) |
@krisjobs you most likely shared wrong stackblitz since url is same as mine. |
Sorry -> https://stackblitz.com/edit/angular-4lxmjk-gbpd1g I could also reproduce the error when the metadata's selectId is active. I also find it strange, that entityCollectionService update() uses Partial< Hero >, while the changeSetItemFactory/entityCacheDispatcher update() uses Update< Hero > |
@marcinmajkowski may I have a look on your branch? |
@krisjobs I am not sure which branch do you mean. This is where I have implemented a fix (one line changed): https://github.com/marcinmajkowski/platform/tree/2059 . |
@krisjobs I was able to update multiple entities at once using following code:
There was no need for accessing dispatcher directly and no error occured. I was also able to dispatch your |
@marcinmajkowski , you can call |
Please refer to my updated stackblitz @ https://stackblitz.com/edit/angular-4lxmjk-gbpd1g -> example.component.ts @JiaLiPassion exactly, I would like to simultaneously make multiple CRUD saves on the back end side. I haven't tested the upsert operation (maybe I can use it as a workaround) but update does not work. Add/Delete do work. |
@krisjobs, yeah, maybe |
@JiaLiPassion I've just tested it and it turns out dispatcher->upsert works properly, as it expects T[] and not Update[] as argument. It's just dispatcher->update that isn't working |
@krisjobs , thanks for the clarification! |
I just found my problem was related to the fact, that as explained here:
This is due to the fact update objects get flattened: |
Minimal reproduction of the bug/regression with instructions:
https://stackblitz.com/edit/angular-4lxmjk
Use
@ngrx/data
and define entity with following properties:entityDispatcherOptions.optimisticUpdate
set totrue
selectId
selecting property other thanid
(it is_id
in my case).Extend
EntityCollectionServiceBase
and call itsupdate
method (click "Update Foo name" button in Stackblitz application).Update fails with following error:
Expected behavior:
Optimistic update works same way as for entities with id named
id
.Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):
Any browser.
@ngrx/[email protected]
.Other information:
My quick guess is that this mustBeEntity call should be replaced with call to
mustBeUpdate
.I would be willing to submit a PR to fix this issue
[X] Yes (Assistance is provided if you need help submitting a pull request)
[ ] No
The text was updated successfully, but these errors were encountered: