Skip to content

Instantly share code, notes, and snippets.

@yusinto
Created October 3, 2017 03:11
Show Gist options
  • Save yusinto/2afe55655124f26af629a819b69ff6ad to your computer and use it in GitHub Desktop.
Save yusinto/2afe55655124f26af629a819b69ff6ad to your computer and use it in GitHub Desktop.
Example apollo landing component
import {createNetworkInterface, ApolloClient, ApolloProvider} from 'react-apollo';
import {SubscriptionClient} from 'subscriptions-transport-ws';
import {addGraphQLSubscriptions} from 'add-graphql-subscriptions';
let networkInterface = createNetworkInterface({uri: config.graphcool.simpleApi});
const wsClient = new SubscriptionClient(config.graphcool.subscriptions, {
// See https://github.com/apollographql/subscriptions-transport-ws/issues/220
// for why the timeout should be set to 30000.
timeout: 30000,
reconnect: true,
});
networkInterface = addGraphQLSubscriptions(networkInterface, wsClient);
const apolloClient = new ApolloClient({networkInterface});
export default () =>
<ApolloProvider client={apolloClient}>
<GraphqlComponent/>
</ApolloProvider>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment