-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapollo.js
More file actions
24 lines (18 loc) · 685 Bytes
/
Copy pathapollo.js
File metadata and controls
24 lines (18 loc) · 685 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws'
// YOUR_GRAPH_QL_ENDPOINT_HERE
const wsClient = new SubscriptionClient('wss://subscriptions.graph.cool/v1/cj3xgn6d2idze0104n3mpq4le', {
reconnect: true,
});
const networkInterface = createNetworkInterface({
uri: 'https://api.graph.cool/simple/v1/cj3xgn6d2idze0104n3mpq4le'
});
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient
)
const client = new ApolloClient({
networkInterface: networkInterfaceWithSubscriptions,
dataIdFromObject: o => o.id
});
export default client;