import type { SchemaTypes } from '@pothos/core'; import { getFieldData, getModel } from './datamodel'; export function getFieldDescription( model: string, builder: PothosSchemaTypes.SchemaBuilder, fieldName: string, description?: string | false, ) { const { exposeDescriptions } = builder.options.prisma; const usePrismaDescription = exposeDescriptions === true || (typeof exposeDescriptions === 'object' && exposeDescriptions?.fields === true); return ( (usePrismaDescription ? (description ?? getFieldData(model, builder, fieldName).documentation) : description) || undefined ); } export function getModelDescription( model: string, builder: PothosSchemaTypes.SchemaBuilder, description?: string | false, ) { const { exposeDescriptions } = builder.options.prisma; const usePrismaDescription = exposeDescriptions === true || (typeof exposeDescriptions === 'object' && exposeDescriptions?.models === true); return ( (usePrismaDescription ? (description ?? getModel(model, builder).documentation) : description) || undefined ); }