Skip to content

Instantly share code, notes, and snippets.

@rcy
Created May 18, 2017 23:51
Show Gist options
  • Save rcy/c205c1a14d19da3356860375f25c48d8 to your computer and use it in GitHub Desktop.
Save rcy/c205c1a14d19da3356860375f25c48d8 to your computer and use it in GitHub Desktop.
apollo client setup for meteor
import { createMeteorNetworkInterface, meteorClientConfig } from 'meteor/apollo';
import { ApolloClient } from 'react-apollo';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
const wsClient = new SubscriptionClient('ws://localhost:5000/', {
reconnect: true,
});
// Create a normal network interface:
const networkInterface = createMeteorNetworkInterface();
// Extend the network interface with the WebSocket
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient
);
// Finally, create your ApolloClient instance with the modified network interface
export const apolloClient = new ApolloClient(meteorClientConfig({
networkInterface: networkInterfaceWithSubscriptions,
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment