summaryrefslogtreecommitdiffstats
path: root/frontend
diff options
context:
space:
mode:
authorWes Bos <wesbos@gmail.com>2018-04-05 14:00:50 -0400
committerWes Bos <wesbos@gmail.com>2018-04-05 14:00:50 -0400
commitfdc7ae6a0a0cced82791bd03cf575f2fa68fca99 (patch)
tree96f6a5f9243af9b402a16bb18355093e2c2387c3 /frontend
parentf4f10d5eb690a33dd1c112358457a2b987297f26 (diff)
clean up withData
Diffstat (limited to 'frontend')
-rw-r--r--frontend/components/Signin.js3
-rw-r--r--frontend/lib/withData.js34
2 files changed, 3 insertions, 34 deletions
diff --git a/frontend/components/Signin.js b/frontend/components/Signin.js
index e701e94..238e167 100644
--- a/frontend/components/Signin.js
+++ b/frontend/components/Signin.js
@@ -15,7 +15,8 @@ class Signin extends Component {
e.preventDefault();
const res = await signin();
localStorage.setItem('token', res.data.signin.token);
- client.query({ query: CURRENT_USER_QUERY, fetchPolicy: 'network-only' });
+ // client.query({ query: CURRENT_USER_QUERY, fetchPolicy: 'network-only' });
+ client.query({ query: CURRENT_USER_QUERY });
};
saveToState = e => {
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 });