Fix tasks (#5199)
## Query depth deprecation I'm deprecating depth parameter in our graphql query / cache tooling. They were obsolete since we introduce the possibility to provide RecordGqlFields ## Refactor combinedFindManyRecordHook The hook can now take an array of operationSignatures ## Fix tasks issues Fix optimistic rendering issue. Note that we still haven't handle optimisticEffect on creation properly
This commit is contained in:
@ -1,36 +1,32 @@
|
||||
import { isUndefined } from '@sniptt/guards';
|
||||
|
||||
import { RecordGqlOperationGqlRecordFields } from '@/object-record/graphql/types/RecordGqlOperationGqlRecordFields';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { FieldMetadataItem } from '../types/FieldMetadataItem';
|
||||
|
||||
export const shouldFieldBeQueried = ({
|
||||
field,
|
||||
depth,
|
||||
queryFields,
|
||||
recordGqlFields,
|
||||
}: {
|
||||
field: Pick<FieldMetadataItem, 'name' | 'type'>;
|
||||
depth?: number;
|
||||
objectRecord?: ObjectRecord;
|
||||
queryFields?: Record<string, any>;
|
||||
recordGqlFields?: RecordGqlOperationGqlRecordFields;
|
||||
}): any => {
|
||||
if (!isUndefined(depth) && depth < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
!isUndefined(depth) &&
|
||||
depth < 1 &&
|
||||
field.type === FieldMetadataType.Relation
|
||||
isUndefinedOrNull(recordGqlFields) &&
|
||||
field.type !== FieldMetadataType.Relation
|
||||
) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
isDefined(recordGqlFields) &&
|
||||
isDefined(recordGqlFields[field.name]) &&
|
||||
recordGqlFields[field.name] !== false
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isDefined(queryFields) && !queryFields[field.name]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user