Fix capture exception for metadata and core (#3335)
This commit is contained in:
@ -9,14 +9,18 @@ import {
|
||||
import { GraphQLSchema, GraphQLError } from 'graphql';
|
||||
import GraphQLJSON from 'graphql-type-json';
|
||||
import { JsonWebTokenError, TokenExpiredError } from 'jsonwebtoken';
|
||||
import { GraphQLSchemaWithContext, YogaInitialContext } from 'graphql-yoga';
|
||||
import {
|
||||
GraphQLSchemaWithContext,
|
||||
YogaInitialContext,
|
||||
maskError,
|
||||
} from 'graphql-yoga';
|
||||
|
||||
import { TokenService } from 'src/core/auth/services/token.service';
|
||||
import { CoreModule } from 'src/core/core.module';
|
||||
import { Workspace } from 'src/core/workspace/workspace.entity';
|
||||
import { WorkspaceFactory } from 'src/workspace/workspace.factory';
|
||||
import { ExceptionHandlerService } from 'src/integrations/exception-handler/exception-handler.service';
|
||||
import { globalExceptionHandler } from 'src/filters/utils/global-exception-handler.util';
|
||||
import { handleExceptionAndConvertToGraphQLError } from 'src/filters/utils/global-exception-handler.util';
|
||||
|
||||
@Injectable()
|
||||
export class GraphQLConfigService
|
||||
@ -29,10 +33,24 @@ export class GraphQLConfigService
|
||||
) {}
|
||||
|
||||
createGqlOptions(): YogaDriverConfig {
|
||||
const exceptionHandlerService = this.exceptionHandlerService;
|
||||
|
||||
return {
|
||||
context: ({ req }) => ({ req }),
|
||||
autoSchemaFile: true,
|
||||
include: [CoreModule],
|
||||
maskedErrors: {
|
||||
maskError(error: GraphQLError, message, isDev) {
|
||||
if (error.originalError) {
|
||||
return handleExceptionAndConvertToGraphQLError(
|
||||
error.originalError,
|
||||
exceptionHandlerService,
|
||||
);
|
||||
}
|
||||
|
||||
return maskError(error, message, isDev);
|
||||
},
|
||||
},
|
||||
conditionalSchema: async (context) => {
|
||||
try {
|
||||
let workspace: Workspace;
|
||||
@ -63,7 +81,10 @@ export class GraphQLConfigService
|
||||
});
|
||||
}
|
||||
|
||||
throw globalExceptionHandler(error, this.exceptionHandlerService);
|
||||
throw handleExceptionAndConvertToGraphQLError(
|
||||
error,
|
||||
this.exceptionHandlerService,
|
||||
);
|
||||
}
|
||||
},
|
||||
resolvers: { JSON: GraphQLJSON },
|
||||
|
||||
Reference in New Issue
Block a user