Return mutation result as entity object#2612
Conversation
220c2c5 to
ac82326
Compare
|
@alanpoulain Currently breaks custom Since we are now re-using the same GraphQL-type, I don't think we can add the fields dynamically. Any ideas? — |
ac82326 to
a4b000c
Compare
|
@alanpoulain I have modified the failing test, but need some input on wether or not this should be the "correct" behaviour. |
|
@lukasluecke I've done some modifications to handle delete like the other mutations (I've changed my mind about it sorry), to manage the normalization context correctly and I've fixed some latent issues. I will push these modifications to your branch today I hope, if you're okay with that. |
|
@alanpoulain Sure, no problem at all 🙂 |
84f3d10 to
41829f9
Compare
|
Done. The changes:
@lukasluecke please tell me if you are okay with the changes 🙂 |
|
@alanpoulain I fear that adding these new wrapper types might lead back to the original issue, because the Apollo client, which is afaik the most popular JS client, would not "match" this for caching purposes
The Relay spec is not totally clear about this, but from my understanding it also expects the "real" type (and full object) to get returned, not just a "similar" object. Which lead me to my earlier comment:
I'll leave this decision up to you, but personally I'd prefer ease of use over the marginal flexibility. |
|
It only says that you need to query all the fields that changed, in order to get them updated in the cache.
The problem is that the `__typename` is part of the cache key in Apollo, which means that using different types will break it . That is also the reason why the issue currently exists (pre-PR), since all the other fields of the object have always been there and identical (including id).
… Am 21.03.2019 um 15:57 schrieb Alan Poulain ***@***.***>:
You're right, this is really not clear. But in this part: https://www.apollographql.com/docs/react/advanced/caching.html#automatic-updates <https://www.apollographql.com/docs/react/advanced/caching.html#automatic-updates>, this sentence seems to say the output of a mutation could be different from the queried data: One nice way to take advantage of this property as much as possible is to make your mutation results have all of the data necessary to update the queries previously fetched..
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#2612 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AGWC_p59wdvAySfrxx7akJVGwb0mlKZaks5vY53bgaJpZM4btSrd>.
|
|
I deleted my previous comment because it was wrong indeed. Maybe a solution would be to change the type only if the normalization context is different. WDYT? |
|
I think that's a good idea! 👍 If you have time to make the changes, I'd appreciate it - otherwise I'll try to squeeze them in next week 🙂 We should also |
|
Done 🙂 |
19e1751 to
dddc321
Compare
… is used for the mutation
dddc321 to
3a1b1fb
Compare
|
Thank you @lukasluecke! |
See #2605 for details.