UNPKG

1.33 kBJavaScriptView Raw
1"use strict";
2/**
3 * The API surface of this module has been heavily inspired by the "type-graphql" library (https://github.com/MichalLytek/type-graphql), originally designed & released by Michal Lytek.
4 * In the v6 major release of NestJS, we introduced the code-first approach as a compatibility layer between this package and the `@nestjs/graphql` module.
5 * Eventually, our team decided to reimplement all the features from scratch due to a lack of flexibility.
6 * To avoid numerous breaking changes, the public API is backward-compatible and may resemble "type-graphql".
7 */
8Object.defineProperty(exports, "__esModule", { value: true });
9exports.registerEnumType = void 0;
10const lazy_metadata_storage_1 = require("../schema-builder/storages/lazy-metadata.storage");
11const type_metadata_storage_1 = require("../schema-builder/storages/type-metadata.storage");
12/**
13 * Registers a GraphqQL enum type based on the passed enumerator reference.
14 * @param options
15 */
16function registerEnumType(enumRef, options) {
17 lazy_metadata_storage_1.LazyMetadataStorage.store(() => type_metadata_storage_1.TypeMetadataStorage.addEnumMetadata({
18 ref: enumRef,
19 name: options.name,
20 description: options.description,
21 valuesMap: options.valuesMap || {},
22 }));
23}
24exports.registerEnumType = registerEnumType;