Created
July 11, 2019 14:11
-
-
Save wawhal/96e336cf63703cdf2f8c00e079ed3d60 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // Installation | |
| // yarn add apollo-boost apollo-link-ws subscriptions-transport-ws react-apollo graphql | |
| // npm install --save apollo-boost apollo-link-ws subscriptions-transport-ws react-apollo graphql | |
| import React from 'react'; | |
| import { View, Text } from 'react-native'; | |
| import { ApolloClient } from 'apollo-client'; | |
| import { WebSocketLink } from 'apollo-link-ws'; | |
| import { InMemoryCache } from 'apollo-cache-inmemory'; | |
| import { ApolloProvider } from 'react-apollo'; | |
| const link = new WebSocketLink({ | |
| uri: "ws://localhost:8080/v1/graphql", | |
| options: { | |
| reconnect: true | |
| } | |
| }); | |
| const cache = new InMemoryCache(); | |
| const client = new ApolloClient({ | |
| link, | |
| cache | |
| }); | |
| const App = () => ( | |
| <ApolloProvider client={client}> | |
| <View><Text>Hello world</Text></View> | |
| </ApolloProvider> | |
| ); | |
| export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment