Skip to content

Instantly share code, notes, and snippets.

@akoenig
Created March 4, 2018 07:41
Show Gist options
  • Save akoenig/93f610678d29960752a491e2470144a7 to your computer and use it in GitHub Desktop.
Save akoenig/93f610678d29960752a491e2470144a7 to your computer and use it in GitHub Desktop.
// graphql/index.js
import ApolloClient, { createNetworkInterface } from "react-apollo";
const createClient = ({ endpointUri: uri, onError }) => {
const networkInterface = createNetworkInterface({ uri });
networkInterface.useAfter([{
applyAfterware({ response }, next) {
if (response.status === 500) {
return onError(new Error(`A fatal error occurred`));
}
next();
}
}]);
return new ApolloClient({ networkInterface });
};
export { createClient };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment