import { Type } from '@nestjs/common'; import { Field, FieldOptions, ObjectType } from '@nestjs/graphql'; import { ApplyType } from '../utils/types'; export function registerObjectType( fields: Record< string, { type: () => Type; options?: FieldOptions; } >, options: { name: string; } ) { const Inner = ApplyType(); for (const [key, { type, options }] of Object.entries(fields)) { Field(type, options)(Inner.prototype, key); } ObjectType(options.name)(Inner); return Inner; }