Feat/metadata datatable types (#2175)

* Handled new url v2 type

* Fixed refetch queries

* wip

* Ok delete but views bug

* Fix lint

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Lucas Bordeau
2023-10-21 14:07:18 +02:00
committed by GitHub
parent 598fda8f45
commit f1670f0cf4
50 changed files with 1125 additions and 350 deletions

View File

@ -15,13 +15,17 @@ import { useApolloMetadataClient } from './useApolloMetadataClient';
export const useFindManyMetadataObjects = () => {
const apolloMetadataClient = useApolloMetadataClient();
const { data, fetchMore: fetchMoreInternal } = useQuery<
MetadataObjectsQuery,
MetadataObjectsQueryVariables
>(FIND_MANY_METADATA_OBJECTS, {
client: apolloMetadataClient ?? undefined,
skip: !apolloMetadataClient,
});
const {
data,
fetchMore: fetchMoreInternal,
loading,
} = useQuery<MetadataObjectsQuery, MetadataObjectsQueryVariables>(
FIND_MANY_METADATA_OBJECTS,
{
client: apolloMetadataClient ?? undefined,
skip: !apolloMetadataClient,
},
);
const hasMore = data?.objects?.pageInfo?.hasNextPage;
@ -38,23 +42,10 @@ export const useFindManyMetadataObjects = () => {
});
}, [data]);
const getMetadataObjectsFromCache = () => {
const queryResult = apolloMetadataClient?.readQuery<
MetadataObjectsQuery,
MetadataObjectsQueryVariables
>({
query: FIND_MANY_METADATA_OBJECTS,
});
return formatPagedMetadataObjectsToMetadataObjects({
pagedMetadataObjects: queryResult ?? undefined,
});
};
return {
metadataObjects,
hasMore,
fetchMore,
getMetadataObjectsFromCache,
loading,
};
};