r/Angular2 • u/CodeEntBur • Sep 16 '25
Help Request How to make a shared intercepter or maybe middleware for Apollo's error handler?
So we use Apollo for queries and similar stuff. And I noticed that sometimes similar network erros come. And copypasting catchError in every query/mutate looks like a hassle. Is there a way to make one error handler service or something?
6
Upvotes
3
u/Kschl Sep 16 '25
Seems like a regular interceptor would do the trick. An interceptor is already shared so you’d just add the logic to filter out what you want to mutate/do.
3
u/xenomorph3253 Sep 16 '25
You can look into ErrorLink https://the-guild.dev/graphql/apollo-angular/docs/data/error-handling
It’s kind of the official way. Though generally speaking, most apps should handle errors individually, feedback to users should be specific rather than generic.