forked from 2fd/graphdoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavigation.schema.ts
53 lines (46 loc) · 1.36 KB
/
navigation.schema.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
import { NavigationSectionInterface, PluginInterface } from "../lib/interface";
import { NavigationItem, NavigationSection, Plugin } from "../lib/utility";
export default class NavigationSchema extends Plugin
implements PluginInterface {
getNavigations(buildFrom?: string): NavigationSectionInterface[] {
if (
!this.document.queryType &&
!this.document.mutationType &&
!this.document.subscriptionType
) {
return []
}
const section = new NavigationSection("Schema", []);
// Query
if (this.document.queryType) {
section.items.push(
new NavigationItem(
this.document.queryType.name,
this.url(this.document.queryType),
buildFrom === this.document.queryType.name
)
);
}
// Mutation
if (this.document.mutationType) {
section.items.push(
new NavigationItem(
this.document.mutationType.name,
this.url(this.document.mutationType),
buildFrom === this.document.mutationType.name
)
);
}
// Subscription
if (this.document.subscriptionType) {
section.items.push(
new NavigationItem(
this.document.subscriptionType.name,
this.url(this.document.subscriptionType),
buildFrom === this.document.subscriptionType.name
)
);
}
return [section];
}
}