UNPKG

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