UNPKG

@pothos/core

Version:

Pothos (formerly GiraphQL) is a plugin based schema builder for creating code-first GraphQL schemas in typescript

55 lines (54 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _export(target, all) { for(var name in all)Object.defineProperty(target, name, { enumerable: true, get: Object.getOwnPropertyDescriptor(all, name).get }); } _export(exports, { get normalizeEnumValues () { return normalizeEnumValues; }, get valuesFromEnum () { return valuesFromEnum; } }); function normalizeEnumValues(values) { const result = {}; if (Array.isArray(values)) { for (const key of values){ result[String(key)] = { pothosOptions: {} }; } } else { for (const [key, value] of Object.entries(values)){ if (value && typeof value === 'object') { result[key] = { ...value, pothosOptions: value }; } else if (typeof value === 'string') { result[value] = { pothosOptions: {} }; } } } return result; } function valuesFromEnum(Enum, values) { const result = {}; for (const key of Object.keys(Enum).filter((key)=>typeof Enum[Enum[key]] !== 'number')){ result[key] = { value: Enum[key], pothosOptions: {}, ...values === null || values === void 0 ? void 0 : values[key] }; } return result; } //# sourceMappingURL=enums.js.map