tekk
10/20/2017, 11:17 PMsubscriptions-transport-ws
and the documentation mentions a keep-alive. Does anyone know where graph cool utilizes a keep alive with it's subscription endpoints?nilan
10/21/2017, 1:16 AMtekk
10/21/2017, 1:36 AMtekk
10/21/2017, 1:36 AMimport { ApolloClient, createNetworkInterface } from 'apollo-client';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
import ws from 'ws';
import config from '../config';
const wsClient = new SubscriptionClient(
config.graphcool.subscriptionsUri,
{
reconnect: true
},
ws
);
const networkInterface = createNetworkInterface({
uri: config.graphcool.uri
});
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(networkInterface, wsClient);
networkInterface.use([
{
applyMiddleware(req, next) {
// Create the header object if needed.
if (!req.options.headers) {
req.options.headers = {};
}
req.options.headers.authorization = `Bearer ${config.graphcool.token}`;
next();
}
}
]);
export default new ApolloClient({
networkInterface: networkInterfaceWithSubscriptions
});