Skip to content

Commit 353fee7

Browse files
committed
fix: docs
1 parent 118bc57 commit 353fee7

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

packages/docs/apollo-client.md

+15-30
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,34 @@
11
# apollo-client
2-
To use **Subspace** with `apollo-client`, a composed `ApolloLink` must be defined using the `apollo-link-rxjs` and `reactive-graphl` npm packages. Notice that the `addTypename` option of `InMemoryCache` must be set `false`.
2+
To use **Subspace** with `apollo-client`, a `ReactiveSchemaLink` from `apollo-link-reactive-schema` must be used with a custom schema.
33

44
```js
5-
import { ApolloClient } from "apollo-client";
6-
import { InMemoryCache } from "apollo-cache-inmemory";
7-
import { ApolloLink } from "apollo-link";
8-
import { rxjs as rxJsLink } from "apollo-link-rxjs";
9-
import { graphql } from "reactive-graphql";
5+
import {InMemoryCache} from "apollo-cache-inmemory";
6+
import ApolloClient from "apollo-client";
7+
import {ReactiveSchemaLink} from "apollo-link-reactive-schema";
108

9+
const schema = makeExecutableSchema({typeDefs, resolvers});
1110
const client = new ApolloClient({
12-
// If addTypename:true, the query will fail due to __typename
13-
// being added to the schema. reactive-graphql does not
14-
// support __typename at this moment.
15-
cache: new InMemoryCache({ addTypename: false }),
16-
link: ApolloLink.from([
17-
rxJsLink({}),
18-
new ApolloLink(operation => graphql(schema, operation.query))
19-
])
11+
cache: new InMemoryCache(),
12+
link: new ReactiveSchemaLink({schema)})
2013
});
14+
2115
```
2216

2317
### Example
2418

2519
```js{35-45}
2620
import { ApolloClient } from "apollo-client";
2721
import { InMemoryCache } from "apollo-cache-inmemory";
28-
import { ApolloLink } from "apollo-link";
29-
import { rxjs as rxJsLink } from "apollo-link-rxjs";
30-
import { graphql } from "reactive-graphql";
22+
import {ReactiveSchemaLink} from "apollo-link-reactive-schema";
23+
import Subspace from "@embarklabs/subspace";
3124
3225
// ...
3326
3427
// Initialize Subspace
35-
const subspace = new Subspace(web3.currentProvider); // Use a valid provider (geth, parity, infura...)
28+
const subspace = new Subspace(web3);
3629
await subspace.init();
3730
38-
const MyContractInstance = ...; // TODO: obtain a web3.eth.contract instance
31+
const MyContractInstance = ...; // TODO: obtain a web3.eth.Contract instance
3932
4033
const typeDefs = `
4134
type MyEvent {
@@ -49,23 +42,15 @@ const typeDefs = `
4942
5043
const resolvers = {
5144
Query: {
52-
myEvents: () => {
53-
return subspace.trackEvent(MyContractInstance, 'MyEvent', {filter: {}, fromBlock: 1})
54-
}
45+
myEvents: () => subspace.trackEvent(MyContractInstance, 'MyEvent', {filter: {}, fromBlock: 1})
5546
}
5647
};
5748
5849
const schema = makeExecutableSchema({ typeDefs, resolvers });
5950
6051
const client = new ApolloClient({
61-
// If addTypename:true, the query will fail due to __typename
62-
// being added to the schema. reactive-graphql does not
63-
// support __typename at this moment.
64-
cache: new InMemoryCache({ addTypename: false }),
65-
link: ApolloLink.from([
66-
rxJsLink({}),
67-
new ApolloLink(operation => graphql(schema, operation.query))
68-
])
52+
cache: new InMemoryCache(),
53+
link: new ReactiveSchemaLink({schema)})
6954
});
7055
```
7156

0 commit comments

Comments
 (0)