feature/IO-3497-Ant-Design-v5-to-v6 - Checkpoint (Apollo)
This commit is contained in:
@@ -1,14 +1,44 @@
|
||||
import * as Sentry from "@sentry/react";
|
||||
import { onError } from "@apollo/client/link/error";
|
||||
//https://stackoverflow.com/questions/57163454/refreshing-a-token-with-apollo-client-firebase-auth
|
||||
|
||||
const errorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
|
||||
if (graphQLErrors) {
|
||||
const operationName = operation?.operationName || "anonymous";
|
||||
|
||||
if (graphQLErrors?.length) {
|
||||
graphQLErrors.forEach(({ message, locations, path }) => {
|
||||
console.log(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`);
|
||||
});
|
||||
|
||||
Sentry.withScope((scope) => {
|
||||
scope.setLevel("error");
|
||||
scope.setTag("graphql.operationName", operationName);
|
||||
scope.setContext("graphql", {
|
||||
operationName
|
||||
// variables can contain PII; include only if you’re comfortable with it
|
||||
// variables: operation.variables
|
||||
});
|
||||
|
||||
graphQLErrors.forEach((err) => {
|
||||
scope.setContext("graphql.error", {
|
||||
message: err.message,
|
||||
path: err.path,
|
||||
locations: err.locations
|
||||
});
|
||||
Sentry.captureMessage(`[GraphQL] ${err.message}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
if (networkError) console.log(`[Network error]: ${JSON.stringify(networkError)}`);
|
||||
console.log(operation.getContext());
|
||||
|
||||
if (networkError) {
|
||||
console.log(`[Network error]: ${JSON.stringify(networkError)}`);
|
||||
|
||||
Sentry.withScope((scope) => {
|
||||
scope.setLevel("error");
|
||||
scope.setTag("graphql.operationName", operationName);
|
||||
Sentry.captureException(networkError);
|
||||
});
|
||||
}
|
||||
|
||||
return forward(operation);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user