Add metadata query resolvers (#1929)

* Add metadata queries resolvers

* remove hello field

* fix linter
This commit is contained in:
Weiko
2023-10-09 22:54:14 +02:00
committed by GitHub
parent 34d3c452c1
commit ca492808cf
9 changed files with 290 additions and 26 deletions

View File

@ -1,3 +1,5 @@
import { Field, ID, ObjectType } from '@nestjs/graphql';
import {
Column,
CreateDateColumn,
@ -7,6 +9,11 @@ import {
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import {
Authorize,
IDField,
QueryOptions,
} from '@ptc-org/nestjs-query-graphql';
import { ObjectMetadata } from 'src/metadata/object-metadata/object-metadata.entity';
@ -14,29 +21,47 @@ export type FieldMetadataTargetColumnMap = {
[key: string]: string;
};
@ObjectType('field')
@QueryOptions({
defaultResultSize: 10,
maxResultsSize: 100,
disableFilter: true,
disableSort: true,
})
@Authorize({
authorize: (context: any) => ({
workspaceId: { eq: context?.req?.user?.workspace?.id },
}),
})
@Entity('field_metadata')
export class FieldMetadata {
@IDField(() => ID)
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ nullable: false, name: 'object_id' })
objectId: string;
@Field()
@Column({ nullable: false })
type: string;
@Field()
@Column({ nullable: false, name: 'display_name' })
displayName: string;
@Column({ nullable: false, name: 'target_column_name' })
targetColumnName: string;
@Field({ nullable: true })
@Column({ nullable: true, name: 'description', type: 'text' })
description: string;
@Field({ nullable: true })
@Column({ nullable: true, name: 'icon' })
icon: string;
@Field({ nullable: true })
@Column({ nullable: true, name: 'placeholder' })
placeholder: string;
@ -46,12 +71,15 @@ export class FieldMetadata {
@Column('text', { nullable: true, array: true })
enums: string[];
@Field()
@Column({ default: false, name: 'is_custom' })
isCustom: boolean;
@Field()
@Column({ default: false, name: 'is_active' })
isActive: boolean;
@Field()
@Column({ nullable: true, default: true, name: 'is_nullable' })
isNullable: boolean;