Closed MitchellMonaghan closed 4 years ago
Really great idea and quite an easy fix. If the operation has already id present we can skip a generation.
Could be
if (operationType === CacheOperation.ADD && !optimisticResponse[operation][idField])
We will release it in the patch release. As a current workaround, you can simply copy this method with modification on every mutation
CC @darahayes
CC @darahayes
@MitchellMonaghan thanks for reporting this and apologies it took such a long time for us to respond. This is absolutely a bug and it can be fixed with what @wtrocki is suggesting. I'll let you know as soon as a fix is released. In the meantime, if you're really stuck, you can directly copy the createOptimisticResponse
function that @wtrocki linked into your application and make the modification you need until we fix it. Or better yet, if you can do that and then make a pull request back to the project we'd be delighted and we would make sure it gets merged as soon as possible.
@MitchellMonaghan we've just published 0.15.1
of all the offix
packages. Can you try that new release and let me know if it fixes the issue for you? Thanks.
createOptimisticResponse with CacheOperation.ADD creates its own id using generateClientId. If they id prop already has a value can we not blow the existing value away? I already generated a id for this new element and I want to keep it in the format I provided. I know I can work around this using the default apollo update function, this would be a nice thing to have.
Thanks Mitch