refactor(server): role actions definition (#9962)

This commit is contained in:
forehalo
2025-02-06 04:54:34 +00:00
parent 31d251d44f
commit d3843d8f11
18 changed files with 773 additions and 1085 deletions

View File

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