UNPKG

inversify-graphql

Version:

Builds dependency-inverted GraphQL schemas with InversifyJS

36 lines 1.1 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TypeCache = void 0; const object_builder_1 = require("./object-builder"); const interfaces_private_1 = require("./interfaces-private"); /** * Holds singletons of all builders */ class TypeCache extends interfaces_private_1.ITypeCache { constructor(container) { super(); this.container = container; } buildType(builder) { if (typeof builder === 'function') { return this.get(builder).build(); } else if ('inspect' in builder) { return builder; } const fieldCfg = builder; class InlineType extends object_builder_1.InversifyObjectTypeBuilder { config() { return fieldCfg; } } return this.get(InlineType).build(); } get(ctor) { if (!this.container.isBound(ctor)) this.container.bind(ctor).toSelf().inSingletonScope(); return this.container.get(ctor); } } exports.TypeCache = TypeCache; //# sourceMappingURL=type-cache.js.map