diff options
Diffstat (limited to 'frontend/lib/withData.js')
| -rw-r--r-- | frontend/lib/withData.js | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js index ada9675..c823e62 100644 --- a/frontend/lib/withData.js +++ b/frontend/lib/withData.js @@ -5,10 +5,9 @@ import ApolloClient from 'apollo-boost'; const client = new ApolloClient({ uri: 'http://localhost:4444', - // cache: new InMemoryCache().restore(initialState || {}), ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once) request: operation => { - console.log(operation); + // if we're in the client and the user has a token, send it along with the request if (typeof localStorage !== 'undefined' && localStorage.getItem('token')) { operation.setContext({ headers: { @@ -22,34 +21,3 @@ const client = new ApolloClient({ export { client }; export default withApollo({ client }); - -// OPTION 2 - -// import { withData } from 'next-apollo'; -// import { HttpLink } from 'apollo-link-http'; -// import { ApolloLink } from 'apollo-link'; - -// // can also be a function that accepts a `headers` object (SSR only) and returns a config -// const networkLink = new HttpLink({ -// uri: 'http://localhost:4444', // Server URL (must be absolute) -// opts: { -// credentials: 'same-origin', // Additional fetch() options like `credentials` or `headers` -// }, -// }); - -// const middlewareLink = new ApolloLink((operation, forward) => { -// if (typeof localStorage !== 'undefined' && localStorage.getItem('token')) { -// console.log('heyyy'); -// console.log(`Bearer ${localStorage.getItem('token')}`); -// operation.setContext({ -// headers: { -// authorization: `Bearer ${localStorage.getItem('token')}`, -// }, -// }); -// } -// return forward(operation); -// }); - -// const link = middlewareLink.concat(networkLink); - -// export default withData({ link }); |
