Skip to content

Commit

Permalink
Prevent subsequent build of metadata storage
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalLytek committed May 22, 2024
1 parent 27a81a2 commit 9053a66
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/metadata/metadata-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class MetadataStorage {

params: ParamMetadata[] = [];

private hasAlreadyBeenBuilt = false;

collectQueryHandlerMetadata(definition: ResolverMetadata) {
this.queries.push(definition);
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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[]) {
Expand Down

0 comments on commit 9053a66

Please sign in to comment.