From 9053a66aaf4e8cd837a424fa54a26c414b8094b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lytek?= Date: Wed, 22 May 2024 15:39:59 +0200 Subject: [PATCH] Prevent subsequent build of metadata storage --- src/metadata/metadata-storage.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/metadata/metadata-storage.ts b/src/metadata/metadata-storage.ts index 82fe11f09..e2c3b5880 100644 --- a/src/metadata/metadata-storage.ts +++ b/src/metadata/metadata-storage.ts @@ -74,6 +74,8 @@ export class MetadataStorage { params: ParamMetadata[] = []; + private hasAlreadyBeenBuilt = false; + collectQueryHandlerMetadata(definition: ResolverMetadata) { this.queries.push(definition); } @@ -160,6 +162,12 @@ export class MetadataStorage { } build(options: SchemaGeneratorOptions) { + if (this.hasAlreadyBeenBuilt) { + return; + } + + this.hasAlreadyBeenBuilt = true; + this.classDirectives.reverse(); this.fieldDirectives.reverse(); this.argumentDirectives.reverse(); @@ -198,10 +206,11 @@ export class MetadataStorage { this.argumentDirectives = []; this.classExtensions = []; this.fieldExtensions = []; - this.resolverClasses = []; this.fields = []; this.params = []; + + this.hasAlreadyBeenBuilt = false; } private buildClassMetadata(definitions: ClassMetadata[]) {