Skip to content

Commit

Permalink
Lazily access normalizer & filter
Browse files Browse the repository at this point in the history
Otherwise asking this early means they are not
fully created with dependencies injected yet.
  • Loading branch information
CarsonF committed Oct 8, 2024
1 parent 11a6ce6 commit 45ba5a8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/core/graphql/graphql-error-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
GraphQLFormattedError as FormattedError,
GraphQLError,
} from 'graphql';
import { LazyGetter } from 'lazy-get-decorator';
import { JsonSet } from '~/common';
import { ExceptionFilter } from '../exception/exception.filter';
import { ExceptionNormalizer } from '../exception/exception.normalizer';
Expand All @@ -20,14 +21,13 @@ declare module 'graphql' {

@Injectable()
export class GraphqlErrorFormatter {
private readonly normalizer: ExceptionNormalizer;
private readonly filter: ExceptionFilter;
constructor(private readonly moduleRef: ModuleRef) {}

constructor(moduleRef: ModuleRef) {
[this.normalizer, this.filter] = [
moduleRef.get(ExceptionNormalizer, { strict: false }),
moduleRef.get(ExceptionFilter, { strict: false }),
];
@LazyGetter() private get normalizer() {
return this.moduleRef.get(ExceptionNormalizer, { strict: false });
}
@LazyGetter() private get filter() {
return this.moduleRef.get(ExceptionFilter, { strict: false });
}

formatError = (
Expand Down

0 comments on commit 45ba5a8

Please sign in to comment.