MCPcopy Index your code
hub / github.com/JordanKnott/taskcafe / updateApolloCache

Function updateApolloCache

frontend/src/shared/utils/cache.ts:6–31  ·  view source on GitHub ↗
(
  client: DataProxy,
  document: DocumentNode,
  update: UpdateCacheFn<T>,
  variables?: any,
)

Source from the content-addressed store, hash-verified

4type UpdateCacheFn<T> = (cache: T) => T;
5
6export function updateApolloCache<T>(
7 client: DataProxy,
8 document: DocumentNode,
9 update: UpdateCacheFn<T>,
10 variables?: any,
11) {
12 let queryArgs: DataProxy.Query<any, any>;
13 if (variables) {
14 queryArgs = {
15 query: document,
16 variables,
17 };
18 } else {
19 queryArgs = {
20 query: document,
21 };
22 }
23 const cache: T | null = client.readQuery(queryArgs);
24 if (cache) {
25 const newCache = update(cache);
26 client.writeQuery({
27 ...queryArgs,
28 data: newCache,
29 });
30 }
31}
32
33export default updateApolloCache;

Callers 9

ProjectsFunction · 0.85
ProjectFunction · 0.85
LabelManagerEditorFunction · 0.85
DetailsFunction · 0.85
ProjectBoardFunction · 0.85
AdminRouteFunction · 0.85
ProjectsFunction · 0.85
TeamPopupFunction · 0.85
MembersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected