Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit ef50a3c

Browse files
committed
docs(cookbook/graphql): Fixes for client import for AOT
1 parent b7f15e2 commit ef50a3c

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

public/docs/_examples/heroes-graphql/ts/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { AppRoutingModule } from './app-routing.module';
1717
// #docregion import-apollo
1818
// ...
1919
import { ApolloModule } from 'apollo-angular';
20-
import { client } from './client';
20+
import { getClient } from './client';
2121
// ...
2222
// #enddocregion import-apollo
2323

@@ -40,7 +40,7 @@ import { HeroSearchComponent } from './hero-search.component';
4040
// #enddocregion v1
4141
// #docregion v1
4242
AppRoutingModule,
43-
ApolloModule.withClient(client)
43+
ApolloModule.withClient(getClient)
4444
],
4545
// #docregion search
4646
declarations: [
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// #docregion , default-initialization
22
import ApolloClient from 'apollo-client';
33

4-
export const client = new ApolloClient();
4+
const client = new ApolloClient();
5+
export function getClient(): ApolloClient {
6+
return client;
7+
}
58
// #enddocregion default-initialization
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
// #docregion , network-initialization
22
import ApolloClient, { createNetworkInterface } from 'apollo-client';
33

4-
export const client = new ApolloClient({
4+
const client = new ApolloClient({
55
networkInterface: createNetworkInterface({
66
uri: 'http://my-api.graphql.com'
77
})
88
});
9+
10+
export function getClient(): ApolloClient {
11+
return client;
12+
}
913
// #enddocregion network-initialization

public/docs/_examples/heroes-graphql/ts/app/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const client = new ApolloClient({
66
networkInterface,
77
dataIdFromObject: (object: any) => object.id,
88
});
9-
export {
10-
client
9+
export function getClient(): ApolloClient {
10+
return client;
1111
}
1212
// #enddocregion

0 commit comments

Comments
 (0)