diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-02-08 10:41:16 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-02-08 10:41:16 -0500 |
| commit | 19c9683e2126c68cb9d231293162c756d69c51fb (patch) | |
| tree | 4679ca2dee47740aa0bf6fe623513c4242e027e6 /frontend/lib/initApollo.js | |
| parent | eabff7cd396d1f37ceb929e666f082ce57f07919 (diff) | |
WIP
Diffstat (limited to 'frontend/lib/initApollo.js')
| -rw-r--r-- | frontend/lib/initApollo.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/frontend/lib/initApollo.js b/frontend/lib/initApollo.js index 35f5e08..7252a00 100644 --- a/frontend/lib/initApollo.js +++ b/frontend/lib/initApollo.js @@ -17,7 +17,6 @@ function create(initialState) { // 1. Create a link for local state to be managed in Apollo - // 1. connect to our GraphQL API const httpLink = new HttpLink({ uri: endpoint, // Server URL (must be absolute) @@ -28,11 +27,13 @@ function create(initialState) { // 2. One to tack on our auth token on each request const authMiddleware = new ApolloLink((operation, forward) => { + console.log('Adding Auth'); const headers = {}; - if (typeof localStorage !== 'undefined' && localStorage.getItem('auth0IdToken')) { - headers.authorization = `Bearer ${localStorage.getItem('auth0IdToken')}`; + if (typeof localStorage !== 'undefined' && localStorage.getItem('token')) { + headers.authorization = `Bearer ${localStorage.getItem('token')}`; } + console.log({ headers }); operation.setContext({ headers }); return forward(operation); @@ -43,6 +44,10 @@ function create(initialState) { ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once) link: concat(authMiddleware, httpLink), cache: new InMemoryCache().restore(initialState || {}), + defaultOptions: { + query: { errorPolicy: 'all' }, + mutate: { errorPolicy: 'all' }, + }, }); } |
