-
Notifications
You must be signed in to change notification settings - Fork 13
Handle errors in updates #77
Comments
I personally wouldn't make errors part of our cache, I would, however, support the notion of not instantiating a write when our mutation has returned erroneously |
The problem I have right now is that the data I get inside my I'm trying to think about a possible use case for having access to the errors inside the Do you know how that would play into optimistic updates? They would have to be reverted on error, even if we don't write. (I just started rewriting our app with this cache, so not using optimistic updates yet 🙂) |
It won't interfere because before write we delete potential optimistic keys https://github.com/FormidableLabs/urql-exchange-graphcache/blob/master/src/exchange.ts#L201 Should be thoroughly tested though ^^ |
A couple of thoughts here, If the errors indeed lead to null data we shouldn't trigger the update function. I'll double check whether that's indeed the case 👍 Optimistic updates should be unaffected, as said, since we're wiping all optimistic changes completely once the real result comes in, no matter what state it actually arrives in ✨ Lastly, I'm not sure whether updates should be concerned with errors. If your data has optional fields, then it stands to reason that an error may occur on any of these fields, which would leave another part of the data alone. In such a case it'd still make sense to apply updates in a lot of cases and I'd argue it's possibly cleaner to check whether the part of the data that you care about is actually there. In most cases you'd for instance write a "Post" even if an error occurred and you don't have its optional "author" field, to give a crude example. |
I think that as long as the types that will be added for #75 correctly reflect the possible values (i.e. nullability), and/or we don't call the |
I think there should be a clean way to handle mutation errors inside the
update
functions. Right now we only have access toresult: Data
. We should either provide the errors as well, or just not call theupdate
if there's an error?The text was updated successfully, but these errors were encountered: