Created
October 3, 2017 03:11
-
-
Save yusinto/2afe55655124f26af629a819b69ff6ad to your computer and use it in GitHub Desktop.
Example apollo landing component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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