feature/IO-3497-Ant-Design-v5-to-v6 - Checkpoint (Apollo)

This commit is contained in:
Dave
2026-01-13 12:15:19 -05:00
parent f99f8ab7f8
commit 912d503ef8
263 changed files with 800 additions and 681 deletions

View File

@@ -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 youre 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);
});