johnpaulada
3/27/2017 - 9:38 AM

Code snippet for using afterwares in Apollo client.

Code snippet for using afterwares in Apollo client.

/**
 * Using afterwares in Apollo client: http://dev.apollodata.com/core/network.html 
 */

import ApolloClient, { createNetworkInterface } from 'apollo-client';
import {logout} from './logout';

const networkInterface = createNetworkInterface({ uri: '/graphql' });

networkInterface.useAfter([{
  applyAfterware({ response }, next) {
    console.log(response);
    next();
  }
}]);

const client = new ApolloClient({networkInterface});