Commit 0c3c8a59 authored by RAHUL RATHORE's avatar RAHUL RATHORE
Browse files

fix: apollo client fixes

parent c66f3755
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { Apollo } from 'apollo-angular';
import { HttpLink, HttpLinkModule } from 'apollo-angular-link-http';
import { InMemoryCache } from '@apollo/client/core';
import { setContext } from 'apollo-link-context';
import { HttpLink, HttpLinkHandler } from 'apollo-angular/http';
import { ApolloLink, InMemoryCache } from '@apollo/client/core';
import { setContext } from '@apollo/client/link/context';
import { environment } from '../environments/environment';

@NgModule({
	exports: [
		HttpClientModule,
		HttpLinkModule
		HttpClientModule
	],
})
export class GraphQLModule {
	constructor(apollo: Apollo, httpLink: HttpLink) {
	constructor(
		private readonly apollo: Apollo,
		private readonly httpLink: HttpLink
	) {
		const uri = environment.GQL_ENDPOINT;
		const http = httpLink.create({ uri });
		const http: HttpLinkHandler = httpLink.create({ uri });

		const authLink = setContext((_, { headers }) => {
		const authLink: ApolloLink = setContext((_, { headers }) => {
			// get the authentication token from local storage if it exists
			const token = localStorage.getItem('token');
			// return the headers to the context so httpLink can read them
+1 −8
Original line number Diff line number Diff line
import {
	Component,
	ViewChild,
	ElementRef,
	OnInit,
	OnDestroy,
} from '@angular/core';
@@ -12,8 +10,6 @@ import CarrierStatus from '@modules/server.common/enums/CarrierStatus';
import { generateObjectIdString } from '@modules/server.common/utils';
import GeoLocation from '@modules/server.common/entities/GeoLocation';
import { Store } from '../../services/store.service';
import IGeoLocation from '@modules/server.common/interfaces/IGeoLocation';
import { GeoLocationService } from '../../services/geo-location.service';
import { Platform } from '@ionic/angular';
import IOrder from '@modules/server.common/interfaces/IOrder';
import { Subject } from 'rxjs';
@@ -27,9 +23,7 @@ import { takeUntil } from 'rxjs/operators';
export class MainPage implements OnInit, OnDestroy {
	selectedOrder: IOrder;

	private watch: any;
	private isOnline: boolean;
	private isMapRendered: boolean;
	private destroy$ = new Subject<void>();
	isTakenFromAnotherCarrier: boolean = false;

@@ -37,7 +31,6 @@ export class MainPage implements OnInit, OnDestroy {
		private platform: Platform,
		private carrierRouter: CarrierRouter,
		private geolocation: Geolocation,
		private geoLocationService: GeoLocationService,
		private store: Store
	) {}

@@ -134,7 +127,7 @@ export class MainPage implements OnInit, OnDestroy {
			.pipe(takeUntil(this.destroy$))
			.subscribe((o) => {
				this.isTakenFromAnotherCarrier =
					!!o && !!o.carrier && o.carrier !== this.store.carrierId;
					!!o && !!o.carrier && o.carrier.id !== this.store.carrierId;
				this.selectedOrder = o;
			});
	}