Created
March 4, 2018 07:41
-
-
Save akoenig/93f610678d29960752a491e2470144a7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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