/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/plugins/graphql/server/src/services/builders/enums.ts
28 строк
715 B
Alexandre Bodin
chore: remove template configuration from utils
09 мар 2024, 15:08
09 мар 2024, 15:08
8d53207
Код
Авторство
О чём код?
import { enumType } from 'nexus'; import { set } from 'lodash/fp'; import { strings } from '@strapi/utils'; interface Definition { enum: string[]; } /** * Build a Nexus enum type from a Strapi enum attribute * @param {object} definition - The definition of the enum * @param {string[]} definition.enum - The params of the enum * @param {string} name - The name of the enum * @return {NexusEnumTypeDef} */ const buildEnumTypeDefinition = (definition: Definition, name: string) => { return enumType({ name, members: definition.enum.reduce( (acc, value) => set(strings.toRegressedEnumValue(value), value, acc), {} ), }); }; export default () => ({ buildEnumTypeDefinition, });