Create Relation with Fields from both sides (#2480)
* Create relation with fields from both sides * update metadata codegen schema
This commit is contained in:
@ -203,11 +203,14 @@ export type CreateOneRelationInput = {
|
|||||||
|
|
||||||
export type CreateRelationInput = {
|
export type CreateRelationInput = {
|
||||||
description?: InputMaybe<Scalars['String']['input']>;
|
description?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
fromIcon?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
fromLabel: Scalars['String']['input'];
|
||||||
|
fromName: Scalars['String']['input'];
|
||||||
fromObjectMetadataId: Scalars['String']['input'];
|
fromObjectMetadataId: Scalars['String']['input'];
|
||||||
icon?: InputMaybe<Scalars['String']['input']>;
|
|
||||||
label: Scalars['String']['input'];
|
|
||||||
name: Scalars['String']['input'];
|
|
||||||
relationType: Scalars['String']['input'];
|
relationType: Scalars['String']['input'];
|
||||||
|
toIcon?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
toLabel: Scalars['String']['input'];
|
||||||
|
toName: Scalars['String']['input'];
|
||||||
toObjectMetadataId: Scalars['String']['input'];
|
toObjectMetadataId: Scalars['String']['input'];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -33,23 +33,38 @@ export class CreateRelationInput {
|
|||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@Field()
|
@Field()
|
||||||
name: string;
|
fromName: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsNotEmpty()
|
@IsNotEmpty()
|
||||||
@Field()
|
@Field()
|
||||||
label: string;
|
toName: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
@Field()
|
||||||
|
fromLabel: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
@Field()
|
||||||
|
toLabel: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
@Field({ nullable: true })
|
||||||
|
fromIcon?: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
@Field({ nullable: true })
|
||||||
|
toIcon?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Field({ nullable: true })
|
@Field({ nullable: true })
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
|
||||||
@Field({ nullable: true })
|
|
||||||
icon?: string;
|
|
||||||
|
|
||||||
@HideField()
|
@HideField()
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,11 +64,12 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
|||||||
}
|
}
|
||||||
|
|
||||||
const createdFields = await this.fieldMetadataService.createMany([
|
const createdFields = await this.fieldMetadataService.createMany([
|
||||||
|
// FROM
|
||||||
{
|
{
|
||||||
name: record.name,
|
name: record.fromName,
|
||||||
label: record.label,
|
label: record.fromLabel,
|
||||||
description: record.description,
|
description: record.description,
|
||||||
icon: record.icon,
|
icon: record.fromIcon,
|
||||||
isCustom: true,
|
isCustom: true,
|
||||||
targetColumnMap: {},
|
targetColumnMap: {},
|
||||||
isActive: true,
|
isActive: true,
|
||||||
@ -76,14 +77,12 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
|||||||
objectMetadataId: record.fromObjectMetadataId,
|
objectMetadataId: record.fromObjectMetadataId,
|
||||||
workspaceId: record.workspaceId,
|
workspaceId: record.workspaceId,
|
||||||
},
|
},
|
||||||
// NOTE: Since we have to create the field-metadata for the user, we need to use the toObjectMetadata info.
|
// TO
|
||||||
// This is not ideal because we might see some conflicts with existing names.
|
|
||||||
// NOTE2: Once MANY_TO_MANY is supported, we need to use namePlural/labelPlural instead.
|
|
||||||
{
|
{
|
||||||
name: objectMetadataMap[record.fromObjectMetadataId].nameSingular,
|
name: record.toName,
|
||||||
label: objectMetadataMap[record.fromObjectMetadataId].labelSingular,
|
label: record.toLabel,
|
||||||
description: undefined,
|
description: undefined,
|
||||||
icon: objectMetadataMap[record.fromObjectMetadataId].icon,
|
icon: record.toIcon,
|
||||||
isCustom: true,
|
isCustom: true,
|
||||||
targetColumnMap: {},
|
targetColumnMap: {},
|
||||||
isActive: true,
|
isActive: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user