fe5b558477
Closes #5062. Refactoring tables list to avoid rendering all toggles on each sync or schema update while using fresh data: - introducing id for RemoteTables in apollo cache - manually updating the cache for the record that was updated after a sync or schema update instead of fetching all tables again
23 lines
540 B
TypeScript
23 lines
540 B
TypeScript
import { ApolloCache } from '@apollo/client';
|
|
import { Modifiers } from '@apollo/client/cache';
|
|
|
|
import { RemoteTable } from '~/generated-metadata/graphql';
|
|
|
|
export const modifyRemoteTableFromCache = ({
|
|
cache,
|
|
fieldModifiers,
|
|
remoteTableName,
|
|
}: {
|
|
cache: ApolloCache<object>;
|
|
fieldModifiers: Modifiers<RemoteTable>;
|
|
remoteTableName: string;
|
|
}) => {
|
|
const remoteTableCacheId = `RemoteTable:{"name":"${remoteTableName}"}`;
|
|
|
|
cache.modify({
|
|
id: remoteTableCacheId,
|
|
fields: fieldModifiers,
|
|
optimistic: true,
|
|
});
|
|
};
|