UNPKG

@pothos/core

Version:

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

39 lines (38 loc) 1.09 kB
export 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; } export 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