feat: 实现订阅登录成功后自动重连

This commit is contained in:
Ivan Li 2021-07-24 17:37:24 +08:00
parent 6de1f73d47
commit c51228eff9

View File

@ -79,6 +79,9 @@ export const AppApolloClientProvider: FC = ({ children }) => {
authorization: `Bearer ${accessToken}`, authorization: `Bearer ${accessToken}`,
}, },
}); });
const subscriptionClient = (wsLink as any)
.subscriptionClient;
subscriptionClient?.close(false, false);
resolve(forward(operation)); resolve(forward(operation));
}); });
logoutRef.current(); logoutRef.current();
@ -139,9 +142,9 @@ export const AppApolloClientProvider: FC = ({ children }) => {
}:${window.location.port}/api/graphql`, }:${window.location.port}/api/graphql`,
options: { options: {
reconnect: true, reconnect: true,
connectionParams: { connectionParams: () => ({
authorization: `Bearer ${accessTokenRef.current} `, authorization: `Bearer ${accessTokenRef.current} `,
}, }),
}, },
}); });
const httpLink = new HttpLink({ const httpLink = new HttpLink({