summaryrefslogtreecommitdiffstats
path: root/frontend/lib
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-04-04 10:38:21 -0400
committerWes Bos <wesbos@gmail.com>2018-04-04 10:38:21 -0400
commita75b2491758a451283e2a373bb3fbe886520b345 (patch)
treeb45d3c6e0685106c0b08049687244fbc8169b27a /frontend/lib
parent00df450c84f126c75c4adcd322947f8b77a589d9 (diff)
force network policy
Diffstat (limited to 'frontend/lib')
-rw-r--r--frontend/lib/withData.js36
1 files changed, 19 insertions, 17 deletions
diff --git a/frontend/lib/withData.js b/frontend/lib/withData.js
index 1a152a3..5c4614f 100644
--- a/frontend/lib/withData.js
+++ b/frontend/lib/withData.js
@@ -3,25 +3,27 @@ import ApolloClient from 'apollo-boost';
// can also be a function that accepts a `headers` object (SSR only) and returns a config
-export default withApollo({
- 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 (typeof localStorage !== 'undefined' && localStorage.getItem('token')) {
- console.log(`Bearer ${localStorage.getItem('token')}`);
- operation.setContext({
- headers: {
- authorization: `Bearer ${localStorage.getItem('token')}`,
- },
- });
- }
- },
- }),
+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 (typeof localStorage !== 'undefined' && localStorage.getItem('token')) {
+ console.log(`Bearer ${localStorage.getItem('token')}`);
+ operation.setContext({
+ headers: {
+ authorization: `Bearer ${localStorage.getItem('token')}`,
+ },
+ });
+ }
+ },
});
+export { client };
+
+export default withApollo({ client });
+
// OPTION 2
// import { withData } from 'next-apollo';