/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/plugins/graphql/server/src/services/builders/response.ts
30 строк
764 B
Alexandre Bodin
chore: migrate graphql plugin to v5
07 мар 2024, 23:12
07 мар 2024, 23:12
279eb44
Код
Авторство
О чём код?
import { objectType } from 'nexus'; import { prop } from 'lodash/fp'; import type { Schema } from '@strapi/types'; import type { Context } from '../types'; export default ({ strapi }: Context) => { const { naming } = strapi.plugin('graphql').service('utils'); return { /** * Build a type definition for a content API response for a given content type */ buildResponseDefinition(contentType: Schema.ContentType) { const name = naming.getEntityResponseName(contentType); const typeName = naming.getTypeName(contentType); return objectType({ name, definition(t) { t.field('data', { type: typeName, resolve: prop('value'), }); }, }); }, }; };