-
Notifications
You must be signed in to change notification settings - Fork 45
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
Optimistic updates of references not working #12
Comments
The problem does seem to be with the extra source.id field. The Product returned from the data loader has both a brand member containing the full Brand object and a brand.id field containing just the linked id. When the optimistic update fires, the brand.id has been updated to the new value, but the brand object still refers to the old value. If I comment out https://github.com/Weakky/ra-data-opencrud/blob/master/src/getResponseParser.js#L36 so the source.id field never gets created, it appears to fix the problem, but I'm not sure of the broader implications of that change... |
Hey there, Thanks for this issue! You're right about optimistic updates not properly working with reference. However, your suggested fix doesn't work for me. I tried updating the brand of a product and it doesn't work either when removing the field To be honest, these generated The n-to-many fields also have generated fields named I'm gonna dig further to understand what's going on. EDIT: It doesn't work either with |
Thanks for taking a look, and for the overall project -- other than this one issue, it's been working great! I see that the code is the same in ra-data-graphql-simple and ra-data-graphcool - wonder if it's worth asking over there why the dual representations of the data. Also, I wonder if it would simplify to just make the return value look more like the REST version and map the embedded object to |
In the prisma e-commerce example, if you go to the product list screen, edit the first product, change the brand and hit save, you'll see in the list view that the brand shows the old value until 3 seconds later when the new data is refreshed and you see the updated value.
The same appears to be true anytime you update a reference using the opencrud data provider -- but if you switch to one of the rest data providers, the optimistic update works as expected. I haven't had time to fully investigate yet, but it looks like the use of the derived source.id field is somehow screwing up the optimistic update system -- if I hack it to use source_id instead, it fixes it...
The text was updated successfully, but these errors were encountered: