UNPKG

@ptc-org/nestjs-query-graphql

Version:
37 lines 1.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findGraphqlObjectMetadata = findGraphqlObjectMetadata; exports.getGraphqlObjectMetadata = getGraphqlObjectMetadata; exports.getGraphqlObjectName = getGraphqlObjectName; exports.getGraphqlEnumMetadata = getGraphqlEnumMetadata; const graphql_1 = require("@nestjs/graphql"); // `@nestjs/graphql` maps its internals via a `"./*": "./*"` exports wildcard which — unlike legacy CJS // resolution — does NOT append the file extension. The two imports above are used in type positions only // (erased at compile time), but `LazyMetadataStorage` is a runtime value, so its specifier must carry the // explicit `.js` or Node throws `Cannot find module .../lazy-metadata.storage` when the service boots. // eslint-disable-next-line import/extensions const lazy_metadata_storage_js_1 = require("@nestjs/graphql/dist/schema-builder/storages/lazy-metadata.storage.js"); const type_errors_1 = require("../types/type.errors"); /** * @internal */ function findGraphqlObjectMetadata(objType) { return graphql_1.TypeMetadataStorage.getObjectTypesMetadata().find((o) => o.target === objType); } function getGraphqlObjectMetadata(objType, notFoundMsg) { const metadata = findGraphqlObjectMetadata(objType); if (!metadata) { throw new type_errors_1.UnregisteredObjectType(objType, notFoundMsg); } return metadata; } function getGraphqlObjectName(DTOClass, notFoundMsg) { return getGraphqlObjectMetadata(DTOClass, notFoundMsg).name; } // eslint-disable-next-line @typescript-eslint/ban-types function getGraphqlEnumMetadata(objType) { // hack to get enums loaded it may break in the future :( lazy_metadata_storage_js_1.LazyMetadataStorage.load(); return graphql_1.TypeMetadataStorage.getEnumsMetadata().find((o) => o.ref === objType); } //# sourceMappingURL=external.utils.js.map