Added framework for CSI questions & viewing. Schema changes to allow anon viewing of survey BOD-98

This commit is contained in:
Patrick Fic
2020-05-22 13:36:25 -07:00
parent d8c159cde0
commit f7cc4cffa4
64 changed files with 1345 additions and 45 deletions

View File

@@ -29,7 +29,8 @@ const wsLink = new WebSocketLink({
reconnect: true,
connectionParams: async () => {
//const token = localStorage.getItem("token");
const token = await auth.currentUser.getIdToken(true);
const token =
auth.currentUser && (await auth.currentUser.getIdToken(true));
if (token) {
return {
headers: {
@@ -42,7 +43,8 @@ const wsLink = new WebSocketLink({
});
const subscriptionMiddleware = {
applyMiddleware: async (options, next) => {
options.authToken = await auth.currentUser.getIdToken(true);
options.authToken =
auth.currentUser && (await auth.currentUser.getIdToken(true));
next();
},
};
@@ -70,18 +72,21 @@ const link = split(
);
const authLink = setContext((_, { headers }) => {
return auth.currentUser.getIdToken().then((token) => {
if (token) {
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
};
} else {
return { headers };
}
});
return (
auth.currentUser &&
auth.currentUser.getIdToken().then((token) => {
if (token) {
return {
headers: {
...headers,
authorization: token ? `Bearer ${token}` : "",
},
};
} else {
return { headers };
}
})
);
});
const retryLink = new RetryLink({