Skip to content

Commit b2a31aa

Browse files
committed
feat: tree-shaking with apollo-client and apollo-client-rxjs
1 parent 2cc3751 commit b2a31aa

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"peerDependencies": {
3535
"@angular/core": "^2.0.0",
36-
"apollo-client": "^0.6.0",
36+
"apollo-client": "^0.7.0",
3737
"rxjs": "^5.0.0-beta.12 || ^5.0.0-rc.1 || ^5.0.0"
3838
},
3939
"dependencies": {
@@ -49,7 +49,7 @@
4949
"@angular/platform-server": "^2.3.1",
5050
"@types/jest": "^15.1.32",
5151
"@types/lodash": "^4.14.34",
52-
"apollo-client": "^0.6.0",
52+
"apollo-client": "^0.7.1",
5353
"graphql": "^0.8.2",
5454
"graphql-tag": "^1.1.2",
5555
"husky": "^0.12.0",

rollup.config.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ export default {
55
moduleName: 'ng.apollo',
66
globals: {
77
'@angular/core': 'ng.core',
8-
'rxjs/Observable': 'Rx'
8+
'rxjs/Observable': 'Rx',
9+
'rxjs/observable/from': 'Rx.Observable',
10+
'rxjs/observable/fromPromise': 'Rx.Observable',
11+
'apollo-client-rxjs': 'apollo.rxjs',
12+
'apollo-client': 'apollo',
913
}
1014
}

src/Angular2Apollo.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ import { OpaqueToken, Injectable, Inject } from '@angular/core';
22
import { rxify } from 'apollo-client-rxjs';
33
import { ApolloClient, ApolloQueryResult, WatchQueryOptions, MutationOptions, SubscriptionOptions } from 'apollo-client';
44
import { Observable } from 'rxjs/Observable';
5+
import { from } from 'rxjs/observable/from';
6+
import { fromPromise } from 'rxjs/observable/fromPromise';
57
import { FragmentDefinitionNode } from 'graphql';
68

79
import { ApolloQueryObservable } from './ApolloQueryObservable';
810

9-
import 'rxjs/add/observable/from';
10-
import 'rxjs/add/observable/fromPromise';
11-
1211
export interface DeprecatedWatchQueryOptions extends WatchQueryOptions {
1312
fragments?: FragmentDefinitionNode[];
1413
}
@@ -27,11 +26,11 @@ export class Angular2Apollo {
2726
}
2827

2928
public query(options: DeprecatedWatchQueryOptions): Observable<ApolloQueryResult> {
30-
return Observable.fromPromise(this.client.query(options));
29+
return fromPromise(this.client.query(options));
3130
}
3231

3332
public mutate(options: MutationOptions): Observable<ApolloQueryResult> {
34-
return Observable.fromPromise(this.client.mutate(options));
33+
return fromPromise(this.client.mutate(options));
3534
}
3635

3736
public subscribe(options: SubscriptionOptions): Observable<any> {
@@ -40,7 +39,7 @@ export class Angular2Apollo {
4039
throw new Error(`Your version of ApolloClient doesn't support subscriptions`);
4140
}
4241

43-
return Observable.from(this.client.subscribe(options));
42+
return from(this.client.subscribe(options));
4443
}
4544

4645
public getClient(): ApolloClient {

0 commit comments

Comments
 (0)