| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import { HttpClientModule } from '@angular/common/http';
- import { NgModule } from '@angular/core';
- import { Apollo, APOLLO_OPTIONS, ApolloModule } from 'apollo-angular';
- import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
- import { InMemoryCache } from 'apollo-cache-inmemory';
- import { SharedModule } from '../shared/shared.module';
- import { APOLLO_NGRX_CACHE, StateModule } from '../state/state.module';
- import { AppShellComponent } from './components/app-shell/app-shell.component';
- import { BaseDataService } from './providers/data/base-data.service';
- import { API_URL } from '../app.config';
- import { LocalStorageService } from './providers/local-storage/local-storage.service';
- import { DataService } from './providers/data/data.service';
- import { AuthGuard } from './providers/guard/auth.guard';
- export function createApollo(httpLink: HttpLink, ngrxCache: InMemoryCache) {
- return {
- link: httpLink.create({ uri: `${API_URL}/graphql` }),
- cache: ngrxCache,
- };
- }
- @NgModule({
- imports: [
- SharedModule,
- HttpClientModule,
- ApolloModule,
- HttpLinkModule,
- StateModule,
- ],
- exports: [
- SharedModule,
- ],
- providers: [
- {
- provide: APOLLO_OPTIONS,
- useFactory: createApollo,
- deps: [HttpLink, APOLLO_NGRX_CACHE],
- },
- BaseDataService,
- LocalStorageService,
- DataService,
- AuthGuard,
- ],
- declarations: [AppShellComponent],
- })
- export class CoreModule {}
|