forked from altair-graphql/altair
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
52 lines (44 loc) · 1.57 KB
/
main.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 { enableProdMode, ApplicationRef } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableDebugTools } from '@angular/platform-browser';
import { AppModule } from 'app/app.module';
import { environment } from './environments/environment';
import { handleExternalLinks } from 'app/modules/altair/utils/events';
import { handleDeprecations } from 'app/modules/altair/utils/deprecated';
import { debug } from 'app/modules/altair/utils/logger';
import { AltairConfig, setAltairConfig } from 'altair-graphql-core/build/config';
import { AltairConfigOptions } from 'altair-graphql-core/build/config/options';
let initialized = false;
(window as any).AltairGraphQL = {
init(configOptions: AltairConfigOptions = {}) {
if (initialized) {
return;
}
const altairConfig = new AltairConfig(configOptions);
setAltairConfig(altairConfig);
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic([
{
provide: AltairConfig,
useValue: altairConfig,
},
])
.bootstrapModule(AppModule, {
preserveWhitespaces: true,
})
.then((moduleRef) => {
const applicationRef = moduleRef.injector.get(ApplicationRef);
const componentRef = applicationRef.components[0];
if (componentRef) {
enableDebugTools(componentRef);
}
})
.catch((err) => debug.log('Error bootstrapping application:', err));
handleExternalLinks();
handleDeprecations();
initialized = true;
},
plugins: {},
};