-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
52 lines (42 loc) · 1.24 KB
/
index.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
import {
query,
OutputTypeOf,
Post as GeneratedPost,
Author as GeneratedAuthor,
} from "./api.gen";
import { ResultOf } from "@graphql-typed-document-node/core";
const basicQuery = query((q) => [
q.posts((p) => [p.id, p.author((a) => [a.name])]),
]);
// OutputTypeOf
type Post = OutputTypeOf<GeneratedPost>;
type ExpectedOutputOfType = {
__typename?: "Post";
id?: number; // Optional in case it has not been selected on the query, not-null since the gql type is not-null
title?: string; // Optional in case it has not been selected on the query, not-null since the gql type is not-null
author?: OutputTypeOf<GeneratedAuthor> | null; // Optional in case it has not been selected on the query, null since the gql type is null
};
type ActualOutputOfType = {
__typename: "Post" | undefined;
id: number | undefined;
title: string | undefined;
author: OutputTypeOf<GeneratedAuthor> | undefined;
};
// ResultOf
type ResultOfBasicQuery = ResultOf<typeof basicQuery>;
type ExpectedQueryType = {
posts: Array<{
id: number;
author: {
name: string;
} | null
}> | null
}
type ActualQueryType = {
posts: Array<{
id: number;
author: {
name: string;
} | undefined;
}> | undefined
};