apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

Any callback function on a global level or in a mutation to collect optimistic response failures? #11715

Closed karan2227 closed 7 months ago

jerelmiller commented 8 months ago

Hey @karan2227 👋

Would you mind providing a bit more context on what you're looking for? I'm not sure I have enough to go on with just the title alone.

karan2227 commented 7 months ago

We are using functions like writeFragment, writeQuery etc to update the cache. Now if in case there is some variable mismatch with the underlying mutation/query then cache write fails. This used to give a warning but now the new version of apollo package we are seeing these errors.

Question: we want to know if we can programmatically apply a common wrapper function to capture all such errors while using the functions writeFragment, writeQuery, cache.modify.

karan2227 commented 7 months ago

any other way apart from console error, to catch these cache write failures of optimistic response object.

jerelmiller commented 7 months ago

Unfortunately no we don't have any kind of universal or global handler that you can use when using these APIs directly. try/catch is your best best for error cases.

If this is something of interest, do you mind filing a feature request with some more detail on what you're looking for?

jerelmiller commented 7 months ago

I'm going to go ahead and close this. Again, feel free to open up a feature request if you're interested in seeing something like this. Thanks!

github-actions[bot] commented 7 months ago

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better.

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. For general questions, we recommend using StackOverflow or our discord server.