mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
refactor(server): role actions definition (#9962)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user