feat: new relation in graphql-query-runner (#9883)

Fix https://github.com/twentyhq/core-team-issues/issues/300

Within GraphQLQueryRunner the new relation format will be used when the
feature flag `IsNewRelationEnabled` is set to true.
This commit is contained in:
Jérémy M
2025-01-29 17:04:39 +01:00
committed by GitHub
parent 29745c6756
commit 07197d1e6d
31 changed files with 729 additions and 138 deletions

View File

@ -0,0 +1,31 @@
import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface';
import {
GraphqlQueryRunnerException,
GraphqlQueryRunnerExceptionCode,
} from 'src/engine/api/graphql/graphql-query-runner/errors/graphql-query-runner.exception';
import { ObjectMetadataMaps } from 'src/engine/metadata-modules/types/object-metadata-maps';
export const getTargetObjectMetadataOrThrow = (
fieldMetadata: FieldMetadataInterface,
objectMetadataMaps: ObjectMetadataMaps,
) => {
if (!fieldMetadata.relationTargetObjectMetadataId) {
throw new GraphqlQueryRunnerException(
`Relation target object metadata id not found for field ${fieldMetadata.name}`,
GraphqlQueryRunnerExceptionCode.RELATION_TARGET_OBJECT_METADATA_NOT_FOUND,
);
}
const targetObjectMetadata =
objectMetadataMaps.byId[fieldMetadata.relationTargetObjectMetadataId];
if (!targetObjectMetadata) {
throw new GraphqlQueryRunnerException(
`Target object metadata not found for field ${fieldMetadata.name}`,
GraphqlQueryRunnerExceptionCode.RELATION_TARGET_OBJECT_METADATA_NOT_FOUND,
);
}
return targetObjectMetadata;
};