Skip to content

Commit 466a4bb

Browse files
authored
Merge e08071f into dc47765
2 parents dc47765 + e08071f commit 466a4bb

File tree

12 files changed

+81
-48
lines changed

12 files changed

+81
-48
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ cache:
1111
- $HOME/.npm
1212
- $HOME/.yarn-cache
1313
- node_modules
14+
- examples/hello-world/node_modules
1415

1516
notifications:
1617
# disable email notification
@@ -23,10 +24,15 @@ before_install:
2324
- yarn global add coveralls
2425
# remove unused node modules from cache
2526
- npm prune
27+
- (cd examples/hello-world && npm prune)
2628

27-
install: yarn
29+
install:
30+
- yarn
31+
- (cd examples/hello-world && npm i)
2832

29-
script: yarn test
33+
script:
34+
- yarn test
35+
- (cd examples/hello-world && npm test)
3036

3137
after_script:
3238
# send code-coverage report to coveralls

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
### vNEXT
44

55
- Support `es6` modules and `tree-shaking` ([PR #151](https://github.com/apollostack/angular2-apollo/pull/151))
6-
- Make our `Ahead-of-Time` compilation compatible with Angular 2.3.0 ([PR #189](https://github.com/apollostack/angular2-apollo/pull/189))
6+
- Make our `Ahead-of-Time` compilation compatible with Angular 2.3.0 ([PR #189](https://github.com/apollostack/angular2-apollo/pull/189), [PR #195](https://github.com/apollostack/angular2-apollo/pull/195))
77

88
### v0.8.0
99

examples/hello-world/package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,28 @@
99
"client": "ng serve --proxy-conf proxy.conf.json",
1010
"server": "nodemon api/index.js --watch api --exec babel-node",
1111
"build": "./node_modules/.bin/ngc -p src/tsconfig.aot.json",
12+
"test": "npm run build",
1213
"postbuild": "npm run tree-shaking",
1314
"tree-shaking": "node_modules/.bin/rollup -c rollup.config.js"
1415
},
1516
"private": true,
1617
"dependencies": {
17-
"@angular/common": "~2.1.2",
18-
"@angular/compiler": "~2.1.2",
19-
"@angular/compiler-cli": "~2.1.2",
20-
"@angular/core": "~2.1.2",
21-
"@angular/forms": "~2.1.2",
22-
"@angular/http": "~2.1.2",
23-
"@angular/platform-browser": "~2.1.2",
24-
"@angular/platform-browser-dynamic": "~2.1.2",
25-
"@angular/platform-server": "~2.1.2",
26-
"@angular/router": "~3.1.2",
18+
"@angular/common": "~2.3.1",
19+
"@angular/compiler": "~2.3.1",
20+
"@angular/compiler-cli": "~2.3.1",
21+
"@angular/core": "~2.3.1",
22+
"@angular/forms": "~2.3.1",
23+
"@angular/http": "~2.3.1",
24+
"@angular/platform-browser": "~2.3.1",
25+
"@angular/platform-browser-dynamic": "~2.3.1",
26+
"@angular/platform-server": "~2.3.1",
27+
"@angular/router": "~3.3.1",
2728
"angular2-apollo": "file:../../",
2829
"apollo-client": "~0.5.1",
2930
"core-js": "~2.4.0",
30-
"rxjs": "5.0.0-beta.12",
31+
"rxjs": "5.0.0-rc.4",
3132
"ts-helpers": "~1.1.1",
32-
"zone.js": "~0.6.26"
33+
"zone.js": "~0.7.2"
3334
},
3435
"devDependencies": {
3536
"@types/isomorphic-fetch": "0.0.30",

examples/hello-world/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
44
import { ApolloModule } from 'angular2-apollo';
55

66
import { AppComponent } from './app.component';
7-
import { client } from './client';
7+
import { getClient } from './client';
88

99
@NgModule({
1010
declarations: [
@@ -15,7 +15,7 @@ import { client } from './client';
1515
FormsModule,
1616
ReactiveFormsModule,
1717
// Define the default ApolloClient
18-
ApolloModule.withClient(client),
18+
ApolloModule.withClient(getClient),
1919
],
2020
bootstrap: [AppComponent],
2121
})

examples/hello-world/src/app/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ const client = new ApolloClient({
99
}),
1010
});
1111

12-
export {
13-
client
12+
export function getClient(): ApolloClient {
13+
return client;
1414
}

examples/hello-world/src/assets/.gitkeep

Whitespace-only changes.

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
"apollo-client-rxjs": "~0.2.3"
4040
},
4141
"devDependencies": {
42-
"@angular/common": "^2.3.0",
43-
"@angular/compiler": "^2.3.0",
44-
"@angular/compiler-cli": "^2.3.0",
45-
"@angular/core": "^2.3.0",
46-
"@angular/platform-browser": "^2.3.0",
47-
"@angular/platform-browser-dynamic": "^2.3.0",
48-
"@angular/platform-server": "^2.3.0",
42+
"@angular/common": "^2.3.1",
43+
"@angular/compiler": "^2.3.1",
44+
"@angular/compiler-cli": "^2.3.1",
45+
"@angular/core": "^2.3.1",
46+
"@angular/platform-browser": "^2.3.1",
47+
"@angular/platform-browser-dynamic": "^2.3.1",
48+
"@angular/platform-server": "^2.3.1",
4949
"@types/chai": "^3.4.34",
5050
"@types/isomorphic-fetch": "^0.0.30",
5151
"@types/jest": "^15.1.32",

src/Angular2Apollo.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ export interface DeprecatedWatchQueryOptions extends WatchQueryOptions {
1313
fragments?: FragmentDefinition[];
1414
}
1515

16-
export const AngularApolloClient = new OpaqueToken('AngularApolloClient');
16+
export const ApolloClientWrapper = new OpaqueToken('ApolloClientWrapper');
17+
export const ApolloClientInstance = new OpaqueToken('ApolloClientInstance');
1718

1819
@Injectable()
1920
export class Angular2Apollo {
2021
constructor(
21-
@Inject(AngularApolloClient) private client: any,
22+
@Inject(ApolloClientInstance) private client: any,
2223
) {}
2324

2425
public watchQuery(options: DeprecatedWatchQueryOptions): ApolloQueryObservable<ApolloQueryResult> {

src/ApolloModule.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NgModule, ModuleWithProviders } from '@angular/core';
22
import { ApolloClient } from 'apollo-client';
33

4-
import { Angular2Apollo, AngularApolloClient } from './Angular2Apollo';
4+
import { Angular2Apollo, ApolloClientWrapper, ApolloClientInstance } from './Angular2Apollo';
55
import { SelectPipe } from './SelectPipe';
66

77
export const APOLLO_DIRECTIVES = [
@@ -11,24 +11,32 @@ export const APOLLO_PROVIDERS = [
1111
Angular2Apollo,
1212
];
1313

14-
export function defaultApolloClient(client: ApolloClient): any {
15-
return {
16-
provide: AngularApolloClient,
17-
useValue: client,
18-
};
14+
export function getApolloClient(clientFn: () => ApolloClient): ApolloClient {
15+
return clientFn();
16+
}
17+
18+
export function defaultApolloClient(clientFn: () => ApolloClient): any {
19+
return [{
20+
provide: ApolloClientWrapper,
21+
useValue: clientFn,
22+
}, {
23+
provide: ApolloClientInstance,
24+
useFactory: getApolloClient,
25+
deps: [ApolloClientWrapper],
26+
}];
1927
}
2028

2129
@NgModule({
2230
declarations: APOLLO_DIRECTIVES,
2331
exports: APOLLO_DIRECTIVES,
2432
})
2533
export class ApolloModule {
26-
public static withClient(client: ApolloClient): ModuleWithProviders {
34+
public static withClient(clientFn: () => ApolloClient): ModuleWithProviders {
2735
return {
2836
ngModule: ApolloModule,
2937
providers: [
3038
APOLLO_PROVIDERS,
31-
defaultApolloClient(client),
39+
defaultApolloClient(clientFn),
3240
],
3341
};
3442
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export { SelectPipe } from './SelectPipe';
2-
export { Angular2Apollo, AngularApolloClient } from './Angular2Apollo';
2+
export { Angular2Apollo } from './Angular2Apollo';
33
export { ApolloQueryObservable } from './ApolloQueryObservable';
44
export { ApolloModule, APOLLO_PROVIDERS, APOLLO_DIRECTIVES, defaultApolloClient } from './ApolloModule';

0 commit comments

Comments
 (0)