Skip to content

Instantly share code, notes, and snippets.

@wawhal
Created July 11, 2019 14:11
Show Gist options
  • Save wawhal/96e336cf63703cdf2f8c00e079ed3d60 to your computer and use it in GitHub Desktop.
Save wawhal/96e336cf63703cdf2f8c00e079ed3d60 to your computer and use it in GitHub Desktop.
// 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