Skip to content

Instantly share code, notes, and snippets.

@rutvikbhatt9
Last active January 30, 2023 18:00
Show Gist options
  • Save rutvikbhatt9/0194fb0eae469b5d9cb351063957c474 to your computer and use it in GitHub Desktop.
Save rutvikbhatt9/0194fb0eae469b5d9cb351063957c474 to your computer and use it in GitHub Desktop.
import { onError } from "@apollo/client/link/error";
const error = onError((error) => {
const { graphQLErrors, networkError, operation } = error;
if (graphQLErrors) {
console.log('GRAPH QL ERROR', graphQLErrors);
if (!graphQLErrors[0].message) {
console.log('Something went wrong', graphQLErrors[0].name);
} else {
console.log("Error message", graphQLErrors[0].message);
}
} else if (networkError) {
console.log('NETWORK ERROR', networkError);
// Network issue like data or wifi is off or not connected
console.log('Something went wrong in network error');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment