-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoperations.ts
54 lines (47 loc) · 1.76 KB
/
operations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Query, Mutation } from "./graphql";
import { assert, Equals } from "tsafe";
export const QUERIES = {
database: [
"listItems",
"listLastItemSeenByUsers",
"getMyUser",
"searchMentionableUsers",
"getUsers",
"getGroupPinboardIds",
"getItemCounts",
] as const,
workflow: [
"listPinboards",
"getPinboardsByIds",
"getPinboardsByPaths",
"getPinboardByComposerId",
] as const,
grid: ["getGridSearchSummary", "asGridPayload"] as const,
} as const;
type QueriesFromCodeGen = keyof Required<Omit<Query, "__typename">>;
const allQueries = [...QUERIES.database, ...QUERIES.workflow, ...QUERIES.grid];
type QueriesDefinedHere = (typeof allQueries)[number];
// if the below line fails TSC, it means that the list of Queries defined in the schema.graphql doesn't match the list defined in `QUERIES` above
// run `yarn graphql-refresh` to resolve
assert<Equals<QueriesFromCodeGen, QueriesDefinedHere>>();
export const MUTATIONS = {
database: [
"createItem",
"editItem",
"deleteItem",
"claimItem",
"seenItem",
"setWebPushSubscriptionForUser",
"addManuallyOpenedPinboardIds",
"removeManuallyOpenedPinboardIds",
"visitTourStep",
"changeFeatureFlag",
] as const,
} as const;
type MutationsFromCodeGen = keyof Required<Omit<Mutation, "__typename">>;
const allMutations = [...MUTATIONS.database];
type MutationsDefinedHere = (typeof allMutations)[number];
// if the below line fails TSC, it means that the list of Mutations defined in the schema.graphql doesn't match the list defined in `MUTATIONS` above
assert<Equals<MutationsFromCodeGen, MutationsDefinedHere>>();
const allDatabaseOperations = [...QUERIES.database, ...MUTATIONS.database];
export type DatabaseOperation = (typeof allDatabaseOperations)[number];