Fix object metadata view creation issue (#9875)

Fixes https://github.com/twentyhq/core-team-issues/issues/26
Fixes https://github.com/twentyhq/twenty/issues/9350
This commit is contained in:
Charles Bochet
2025-01-27 21:25:02 +01:00
committed by GitHub
parent 549c3faf71
commit 4542199e5c
10 changed files with 48 additions and 73 deletions

View File

@ -1,7 +1,5 @@
import { useApolloClient, useMutation } from '@apollo/client';
import { useMutation } from '@apollo/client';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecordsQuery } from '@/object-record/hooks/useFindManyRecordsQuery';
import {
CreateObjectInput,
CreateOneObjectMetadataItemMutation,
@ -15,14 +13,9 @@ import { useApolloMetadataClient } from './useApolloMetadataClient';
export const useCreateOneObjectMetadataItem = () => {
const apolloMetadataClient = useApolloMetadataClient();
const apolloClient = useApolloClient();
const { refreshObjectMetadataItems } =
useRefreshObjectMetadataItems('network-only');
const { findManyRecordsQuery } = useFindManyRecordsQuery({
objectNameSingular: CoreObjectNameSingular.View,
});
const [mutate] = useMutation<
CreateOneObjectMetadataItemMutation,
CreateOneObjectMetadataItemMutationVariables
@ -42,15 +35,7 @@ export const useCreateOneObjectMetadataItem = () => {
return createdObjectMetadata;
};
const findManyRecordsCache = async () => {
await apolloClient.query({
query: findManyRecordsQuery,
fetchPolicy: 'network-only',
});
};
return {
createOneObjectMetadataItem,
findManyRecordsCache,
};
};