fix: address GraphQL schema cache mismatch errors on page layout queries
https://sonarly.com/issue/35600?type=bug Frontend is calling getPageLayoutWidgets GraphQL query without the required pageLayoutTabId argument, causing a 400 error when users navigate to object list pages like /objects/companies.
This commit is contained in:
@@ -209,6 +209,18 @@ export class ApolloFactory implements ApolloManager {
|
||||
);
|
||||
};
|
||||
|
||||
const isGraphQLValidationError = (
|
||||
graphQLError: GraphQLFormattedError,
|
||||
): boolean => {
|
||||
const message = graphQLError.message.toLowerCase();
|
||||
return (
|
||||
message.includes('required, but it was not provided') ||
|
||||
message.includes('unknown type') ||
|
||||
message.includes('cannot query field') ||
|
||||
message.includes('must have a selection of subfields')
|
||||
);
|
||||
};
|
||||
|
||||
const sendToSentry = ({
|
||||
graphQLError,
|
||||
operation,
|
||||
@@ -225,6 +237,16 @@ export class ApolloFactory implements ApolloManager {
|
||||
}, Path: ${graphQLError.path}`,
|
||||
);
|
||||
}
|
||||
|
||||
if (isGraphQLValidationError(graphQLError)) {
|
||||
if (isDebugMode === true) {
|
||||
logDebug(
|
||||
`[GraphQL validation error ignored]: ${graphQLError.message}`,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
import('@sentry/react')
|
||||
.then(({ captureException, withScope }) => {
|
||||
withScope((scope) => {
|
||||
@@ -251,6 +273,17 @@ export class ApolloFactory implements ApolloManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (isDefined(this.currentWorkspace?.metadataVersion)) {
|
||||
scope.setExtra(
|
||||
'schemaVersion',
|
||||
this.currentWorkspace.metadataVersion,
|
||||
);
|
||||
}
|
||||
|
||||
if (isDefined(this.appVersion)) {
|
||||
scope.setExtra('appVersion', this.appVersion);
|
||||
}
|
||||
|
||||
if (!isEmpty(fingerPrint)) {
|
||||
scope.setFingerprint(fingerPrint);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user