morph backend CORE api (#13517)
# Morph Relation needs some work on the core API Especially on the Morph types <img width="682" height="394" alt="Screenshot 2025-07-31 at 12 19 40" src="https://github.com/user-attachments/assets/8b185ae3-3fe7-4886-97b1-ec143bb1b0f4" /> ## Focus Areas: - GraphQL schema generation - Query parsing and field selection - Morph relation field support - Input type definition preparation
This commit is contained in:
+12
-11
@@ -167,10 +167,10 @@ const generateRelationField = <
|
||||
options: WorkspaceBuildSchemaOptions;
|
||||
typeFactory: TypeFactory<T>;
|
||||
}) => {
|
||||
const relationField = {};
|
||||
const relationFields = {};
|
||||
|
||||
if (fieldMetadata.settings?.relationType === RelationType.ONE_TO_MANY) {
|
||||
return relationField;
|
||||
return relationFields;
|
||||
}
|
||||
|
||||
const { joinColumnName, fieldMetadataName } =
|
||||
@@ -188,14 +188,14 @@ const generateRelationField = <
|
||||
);
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
relationField[joinColumnName] = {
|
||||
relationFields[joinColumnName] = {
|
||||
type,
|
||||
description: fieldMetadata.description,
|
||||
};
|
||||
|
||||
//TODO : temporary - continue ej/1278 branch (https://github.com/twentyhq/core-team-issues/issues/1278 issue) before removing this
|
||||
if (fieldMetadata.type === FieldMetadataType.MORPH_RELATION)
|
||||
return relationField;
|
||||
return relationFields;
|
||||
|
||||
if (
|
||||
[InputTypeDefinitionKind.Create, InputTypeDefinitionKind.Update].includes(
|
||||
@@ -215,15 +215,16 @@ const generateRelationField = <
|
||||
isRelationConnectField: true,
|
||||
},
|
||||
);
|
||||
|
||||
// todo @guillim
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
relationFields[fieldMetadataName] = {
|
||||
type: type,
|
||||
description: fieldMetadata.description,
|
||||
};
|
||||
}
|
||||
|
||||
// @ts-expect-error legacy noImplicitAny
|
||||
relationField[fieldMetadataName] = {
|
||||
type: type,
|
||||
description: fieldMetadata.description,
|
||||
};
|
||||
|
||||
return relationField;
|
||||
return relationFields;
|
||||
};
|
||||
|
||||
// Type guard
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { type ObjectMetadataEntity } from 'src/engine/metadata-modules/object-metadata/object-metadata.entity';
|
||||
import { isMorphRelationFieldMetadataType } from 'src/engine/utils/is-morph-relation-field-metadata-type.util';
|
||||
|
||||
export const objectContainsMorphRelationField = (
|
||||
objectMetadata: ObjectMetadataEntity,
|
||||
): boolean => {
|
||||
return objectMetadata.fields.some((field) =>
|
||||
isMorphRelationFieldMetadataType(field.type),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user