refactor: merge FieldType and FieldMetadataType (#4504)

* refactor: merge FieldType and FieldMetadataType

* fix: fix args passed to assertFieldMetadata

* fix: omit RawJson from supported types in settings
This commit is contained in:
Thaïs
2024-03-25 15:45:28 +01:00
committed by GitHub
parent 9e70f5b650
commit b77d589497
39 changed files with 116 additions and 119 deletions

View File

@ -1,6 +1,6 @@
import { isUndefined } from '@sniptt/guards';
import { FieldType } from '@/object-record/record-field/types/FieldType';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { FieldMetadataItem } from '../types/FieldMetadataItem';
@ -13,18 +13,20 @@ export const shouldFieldBeQueried = ({
depth?: number;
eagerLoadedRelations?: Record<string, boolean>;
}): any => {
const fieldType = field.type as FieldType;
if (!isUndefined(depth) && depth < 0) {
return false;
}
if (!isUndefined(depth) && depth < 1 && fieldType === 'RELATION') {
if (
!isUndefined(depth) &&
depth < 1 &&
field.type === FieldMetadataType.Relation
) {
return false;
}
if (
fieldType === 'RELATION' &&
field.type === FieldMetadataType.Relation &&
!isUndefined(eagerLoadedRelations) &&
(isUndefined(eagerLoadedRelations[field.name]) ||
!eagerLoadedRelations[field.name])