Refactor graphql query runner + fix nested or (#6986)
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
import { FieldMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/field-metadata.interface';
|
||||
import { ObjectMetadataInterface } from 'src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface';
|
||||
|
||||
import {
|
||||
GraphqlQueryRunnerException,
|
||||
GraphqlQueryRunnerExceptionCode,
|
||||
} from 'src/engine/api/graphql/graphql-query-runner/errors/graphql-query-runner.exception';
|
||||
|
||||
export type FieldMetadataMap = Record<string, FieldMetadataInterface>;
|
||||
|
||||
export type ObjectMetadataMapItem = Omit<ObjectMetadataInterface, 'fields'> & {
|
||||
@ -33,3 +38,19 @@ export const convertObjectMetadataToMap = (
|
||||
|
||||
return objectMetadataMap;
|
||||
};
|
||||
|
||||
export const getObjectMetadata = (
|
||||
objectMetadataMap: Record<string, any>,
|
||||
objectName: string,
|
||||
): ObjectMetadataMapItem => {
|
||||
const objectMetadata = objectMetadataMap[objectName];
|
||||
|
||||
if (!objectMetadata) {
|
||||
throw new GraphqlQueryRunnerException(
|
||||
`Object metadata not found for ${objectName}`,
|
||||
GraphqlQueryRunnerExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
);
|
||||
}
|
||||
|
||||
return objectMetadata;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user