Another attempt at fixing broken retry for apollo error handling.
This commit is contained in:
@@ -11,9 +11,11 @@ import "./header.styles.scss";
|
|||||||
export default ({ landingHeader, navItems, selectedNavItem }) => {
|
export default ({ landingHeader, navItems, selectedNavItem }) => {
|
||||||
const apolloClient = useApolloClient();
|
const apolloClient = useApolloClient();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleClick = e => {
|
const handleClick = e => {
|
||||||
apolloClient.writeData({ data: { selectedNavItem: e.key } });
|
apolloClient.writeData({ data: { selectedNavItem: e.key } });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row type='flex' justify='space-around'>
|
<Row type='flex' justify='space-around'>
|
||||||
<Col span={16}>
|
<Col span={16}>
|
||||||
@@ -48,17 +50,6 @@ export default ({ landingHeader, navItems, selectedNavItem }) => {
|
|||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
</Menu.SubMenu>
|
</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 : (
|
{!landingHeader ? null : (
|
||||||
<Menu.Item>
|
<Menu.Item>
|
||||||
<ManageSignInButton />
|
<ManageSignInButton />
|
||||||
|
|||||||
@@ -21,7 +21,10 @@ export default function OwnerFindModalContainer({
|
|||||||
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
|
const ownersList = useQuery(QUERY_SEARCH_OWNER_BY_IDX, {
|
||||||
variables: {
|
variables: {
|
||||||
search: owner
|
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
|
: null
|
||||||
},
|
},
|
||||||
skip: !owner,
|
skip: !owner,
|
||||||
|
|||||||
@@ -5,13 +5,15 @@ import { auth } from "../firebase/firebase.utils";
|
|||||||
|
|
||||||
const errorLink = onError(
|
const errorLink = onError(
|
||||||
({ graphQLErrors, networkError, operation, forward }) => {
|
({ graphQLErrors, networkError, operation, forward }) => {
|
||||||
// console.log("graphQLErrors", graphQLErrors);
|
if (graphQLErrors)
|
||||||
// console.log("networkError", networkError);
|
graphQLErrors.forEach(({ message, locations, path }) =>
|
||||||
// console.log("operation", operation);
|
console.log(
|
||||||
// console.log("forward", forward);
|
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (networkError) console.log(`[Network error]: ${networkError}`);
|
||||||
|
|
||||||
let expired = false;
|
let expired = false;
|
||||||
|
|
||||||
if (graphQLErrors) {
|
if (graphQLErrors) {
|
||||||
if (graphQLErrors[0].message.includes("JWTExpired")) {
|
if (graphQLErrors[0].message.includes("JWTExpired")) {
|
||||||
expired = true;
|
expired = true;
|
||||||
@@ -33,12 +35,14 @@ const errorLink = onError(
|
|||||||
if (token) {
|
if (token) {
|
||||||
console.log("Got the new token.", token);
|
console.log("Got the new token.", token);
|
||||||
window.localStorage.setItem("token", token);
|
window.localStorage.setItem("token", token);
|
||||||
operation.setContext(({ headers = {} }) => ({
|
|
||||||
|
const oldHeaders = operation.getContext().headers;
|
||||||
|
operation.setContext({
|
||||||
headers: {
|
headers: {
|
||||||
...headers,
|
...oldHeaders,
|
||||||
authorization: token ? `Bearer ${token}` : ""
|
authorization: token ? `Bearer ${token}` : ""
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
return forward(operation);
|
return forward(operation);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user