Get all first depth fields in the table and the board (#11650)
After discussing it with the team, we now want to query all fields in the table and the board by default. Feeding the cache with exhaustive data will make the side panel's life easier, as it needs all the record fields to determine the actions to enable.
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import { generateDepthOneWithoutRelationsRecordGqlFields } from '@/object-record/graphql/utils/generateDepthOneWithoutRelationsRecordGqlFields';
|
||||
import { getMockPersonObjectMetadataItem } from '~/testing/mock-data/people';
|
||||
|
||||
describe('generateDepthOneWithoutRelationsRecordGqlFields', () => {
|
||||
const objectMetadataItem = getMockPersonObjectMetadataItem();
|
||||
it('Should handle basic call with standalone objectMetadataItem', () => {
|
||||
const result = generateDepthOneWithoutRelationsRecordGqlFields({
|
||||
objectMetadataItem,
|
||||
});
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
{
|
||||
"avatarUrl": true,
|
||||
"city": true,
|
||||
"companyId": true,
|
||||
"createdAt": true,
|
||||
"createdBy": true,
|
||||
"deletedAt": true,
|
||||
"emails": true,
|
||||
"id": true,
|
||||
"intro": true,
|
||||
"jobTitle": true,
|
||||
"linkedinLink": true,
|
||||
"name": true,
|
||||
"performanceRating": true,
|
||||
"phones": true,
|
||||
"position": true,
|
||||
"searchVector": true,
|
||||
"updatedAt": true,
|
||||
"whatsapp": true,
|
||||
"workPreference": true,
|
||||
"xLink": true,
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
+1
@@ -3,6 +3,7 @@ import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
export type GenerateDepthOneRecordGqlFields = {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
};
|
||||
|
||||
export const generateDepthOneRecordGqlFields = ({
|
||||
objectMetadataItem,
|
||||
}: GenerateDepthOneRecordGqlFields) =>
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
|
||||
type GenerateDepthOneWithoutRelationsRecordGqlFields = {
|
||||
objectMetadataItem: ObjectMetadataItem;
|
||||
};
|
||||
|
||||
export const generateDepthOneWithoutRelationsRecordGqlFields = ({
|
||||
objectMetadataItem,
|
||||
}: GenerateDepthOneWithoutRelationsRecordGqlFields) => {
|
||||
return objectMetadataItem.fields
|
||||
.filter((field) => field.type !== FieldMetadataType.RELATION)
|
||||
.reduce<Record<string, true>>((acc, field) => {
|
||||
return {
|
||||
...acc,
|
||||
[field.name]: true,
|
||||
};
|
||||
}, {});
|
||||
};
|
||||
Reference in New Issue
Block a user