UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

64 lines (63 loc) 2.17 kB
import { ArrayWithGlobalCacheCollection } from './array-with-global-cache.collection.js'; import { FieldDirectiveCollection } from './field-directive.collection.js'; import { MetadataByNameCollection } from './metadata-by-name.collection.js'; import { MetadataListByNameCollection } from './metadata-list-by-name.collection.js'; export class TargetMetadataCollection { constructor(all) { this.all = all; this.fields = new MetadataByNameCollection(); this.params = new MetadataListByNameCollection(); this.fieldDirectives = new FieldDirectiveCollection(this.all.fieldDirectives); this.fieldExtensions = new MetadataListByNameCollection(this.all.fieldExtensions); this.classDirectives = new ArrayWithGlobalCacheCollection(this.all.classDirectives); this.classExtensions = new 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; } } }