Skip to content
This repository was archived by the owner on Jul 1, 2024. It is now read-only.

Commit fc210f4

Browse files
authored
Use Apollo cache for labels/project columns (#356)
1 parent 1a64137 commit fc210f4

File tree

2 files changed

+6
-47
lines changed

2 files changed

+6
-47
lines changed

src/ttl-cache.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/util/cachedQueries.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,23 @@
11
import { TypedDocumentNode } from "@apollo/client/core";
22
import { GetLabels, GetProjectColumns } from "../queries/label-columns-queries";
3-
import { createCache } from "../ttl-cache";
43
import { client } from "../graphql-client";
54
import { noNullish } from "./util";
65

7-
const cache = createCache();
8-
96
export async function getProjectBoardColumns() {
10-
return cache.getAsync("project board colum names", Infinity, async () => {
11-
const res = noNullish((await query(GetProjectColumns))
12-
.repository?.project?.columns.nodes);
13-
return res.sort((a,b) => a.name.localeCompare(b.name));
14-
});
7+
const res = noNullish((await query(GetProjectColumns))
8+
.repository?.project?.columns.nodes);
9+
return res.sort((a,b) => a.name.localeCompare(b.name));
1510
}
1611

1712
export async function getLabels() {
18-
return await cache.getAsync("label ids", Infinity, async () => {
19-
const res = noNullish((await query(GetLabels))
20-
.repository?.labels?.nodes);
21-
return res.sort((a,b) => a.name.localeCompare(b.name));
22-
});
13+
const res = noNullish((await query(GetLabels))
14+
.repository?.labels?.nodes);
15+
return res.sort((a,b) => a.name.localeCompare(b.name));
2316
}
2417

2518
async function query<T>(gql: TypedDocumentNode<T>): Promise<T> {
2619
const res = await client.query({
2720
query: gql,
28-
fetchPolicy: "network-only",
2921
});
3022
return res.data;
3123
}

0 commit comments

Comments
 (0)