UNPKG

636 BPlain TextView Raw
1import ApolloClient from 'apollo-client';
2
3import {
4 Provider,
5 provide,
6 OpaqueToken,
7 Injectable,
8 Inject,
9} from '@angular/core';
10
11export const angularApolloClient = new OpaqueToken('AngularApolloClient');
12export const defaultApolloClient = (client: ApolloClient): Provider => {
13 return provide(angularApolloClient, {
14 useValue: client,
15 });
16};
17
18@Injectable()
19export class Angular2Apollo {
20 constructor(
21 @Inject(angularApolloClient) private client: any
22 ) {
23
24 }
25
26 public watchQuery(options) {
27 return this.client.watchQuery(options);
28 }
29
30 public mutate(options) {
31 return this.client.mutate(options);
32 }
33}