Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 20x 20x 20x 20x 20x 20x 20x 6x 2x 6x 6x 1x 5x 5x 5x 5x 20x | import { GraphQLEnumType } from 'graphql'; import { EnumError } from './error'; import { enumsRegistry } from './registry'; export { enumsRegistry } from './registry'; import { convertNativeEnumToGraphQLEnumValues } from './services'; export interface EnumOptions { name: string; description?: string; } export function registerEnum(enumDef: Object, options: EnumOptions | string) { if (typeof options === 'string') { options = { name: options }; } const { name, description }: EnumOptions = options; if (enumsRegistry.has(enumDef)) { throw new EnumError(name, `Enum is already registered`); } const values = convertNativeEnumToGraphQLEnumValues(enumDef); const enumType = new GraphQLEnumType({ name, description, values, }); enumsRegistry.set(enumDef, enumType); return enumType; } |