@nestjs/graphql
Version:
Nest - modern, fast, powerful node.js web framework (@graphql)
68 lines (67 loc) • 2.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TargetMetadataCollection = void 0;
const array_with_global_cache_collection_1 = require("./array-with-global-cache.collection");
const field_directive_collection_1 = require("./field-directive.collection");
const metadata_by_name_collection_1 = require("./metadata-by-name.collection");
const metadata_list_by_name_collection_1 = require("./metadata-list-by-name.collection");
class TargetMetadataCollection {
constructor(all) {
this.all = all;
this.fields = new metadata_by_name_collection_1.MetadataByNameCollection();
this.params = new metadata_list_by_name_collection_1.MetadataListByNameCollection();
this.fieldDirectives = new field_directive_collection_1.FieldDirectiveCollection(this.all.fieldDirectives);
this.fieldExtensions = new metadata_list_by_name_collection_1.MetadataListByNameCollection(this.all.fieldExtensions);
this.classDirectives = new array_with_global_cache_collection_1.ArrayWithGlobalCacheCollection(this.all.classDirectives);
this.classExtensions = new array_with_global_cache_collection_1.ArrayWithGlobalCacheCollection(this.all.classExtensions);
}
set argumentType(val) {
this.replaceOrPush(this.all.argumentType, this._argumentType, val);
this._argumentType = val;
}
get argumentType() {
return this._argumentType;
}
set interface(val) {
this._interface = val;
this.all.interface.set(val.target, val);
}
get interface() {
return this._interface;
}
set inputType(val) {
this.replaceOrPush(this.all.inputType, this._inputType, val);
this._inputType = val;
}
get inputType() {
return this._inputType;
}
set objectType(val) {
this.replaceOrPush(this.all.objectType, this._objectType, val);
this._objectType = val;
}
get objectType() {
return this._objectType;
}
set resolver(val) {
this.replaceOrPush(this.all.resolver, this._resolver, val);
this._resolver = val;
}
get resolver() {
return this._resolver;
}
replaceOrPush(list, previous, next) {
if (previous === undefined) {
list.push(next);
return;
}
const index = list.indexOf(previous);
if (index === -1) {
list.push(next);
}
else {
list[index] = next;
}
}
}
exports.TargetMetadataCollection = TargetMetadataCollection;