Another attempt at fixing broken retry for apollo error handling.

This commit is contained in:
Patrick Fic
2020-01-30 18:59:51 -08:00
parent 0225e34f7b
commit f1ac052a1b
3 changed files with 18 additions and 20 deletions

View File

@@ -11,9 +11,11 @@ import "./header.styles.scss";
export default ({ landingHeader, navItems, selectedNavItem }) => {
const apolloClient = useApolloClient();
const { t } = useTranslation();
const handleClick = e => {
apolloClient.writeData({ data: { selectedNavItem: e.key } });
};
return (
<Row type='flex' justify='space-around'>
<Col span={16}>
@@ -48,17 +50,6 @@ export default ({ landingHeader, navItems, selectedNavItem }) => {
</Menu.Item>
</Menu.SubMenu>
{
// navItems.map(navItem => (
// <Menu.Item key={navItem.title}>
// <Link to={navItem.path}>
// {navItem.icontype ? <Icon type={navItem.icontype} /> : null}
// {navItem.title}
// </Link>
// </Menu.Item>
// ))
}
{!landingHeader ? null : (
<Menu.Item>
<ManageSignInButton />

View File

@@ -21,7 +21,10 @@ export default function OwnerFindModalContainer({
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
variables: {
search: owner
? `${owner.ownr_fn} ${owner.ownr_ln} ${owner.ownr_addr1} ${owner.ownr_city} ${owner.ownr_zip} ${owner.ownr_ea} ${owner.ownr_ph1} ${owner.ownr_ph2}`
? `${owner.ownr_fn || ""} ${owner.ownr_ln || ""} ${owner.ownr_addr1 ||
""} ${owner.ownr_city || ""} ${owner.ownr_zip ||
""} ${owner.ownr_ea || ""} ${owner.ownr_ph1 ||
""} ${owner.ownr_ph2 || ""}`
: null
},
skip: !owner,

View File

@@ -5,13 +5,15 @@ import { auth } from "../firebase/firebase.utils";
const errorLink = onError(
({ graphQLErrors, networkError, operation, forward }) => {
// console.log("graphQLErrors", graphQLErrors);
// console.log("networkError", networkError);
// console.log("operation", operation);
// console.log("forward", forward);
if (graphQLErrors)
graphQLErrors.forEach(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
);
if (networkError) console.log(`[Network error]: ${networkError}`);
let expired = false;
if (graphQLErrors) {
if (graphQLErrors[0].message.includes("JWTExpired")) {
expired = true;
@@ -33,12 +35,14 @@ const errorLink = onError(
if (token) {
console.log("Got the new token.", token);
window.localStorage.setItem("token", token);
operation.setContext(({ headers = {} }) => ({
const oldHeaders = operation.getContext().headers;
operation.setContext({
headers: {
...headers,
...oldHeaders,
authorization: token ? `Bearer ${token}` : ""
}
}));
});
return forward(operation);