1 |
|
2 |
|
3 | import ApolloClient from 'apollo-client';
|
4 |
|
5 | import {
|
6 | Provider,
|
7 | provide,
|
8 | OpaqueToken,
|
9 | Injectable,
|
10 | Inject,
|
11 | } from '@angular/core';
|
12 |
|
13 | export const angularApolloClient = new OpaqueToken('AngularApolloClient');
|
14 | export const defaultApolloClient = (client: ApolloClient): Provider => {
|
15 | return provide(angularApolloClient, {
|
16 | useValue: client,
|
17 | });
|
18 | };
|
19 |
|
20 | @Injectable()
|
21 | export 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 | }
|