apollo-link

refresh token for angular using graphql and apollo client

≯℡__Kan透↙ 提交于 2021-01-05 07:34:27
问题 I'm trying to set up a refresh token strategy to refresh JWT in angular 9 with GraphQL and apollo client when my first request returns a 401. I have set up a new angular module for graphql where I'm creating my apolloclient. Everything works great even with authenticated requests but I need to have my normal refresh token strategy work as well (re-make and return the original request after refresh token cycle completes). I have found only a few resources to help with this and I've gotten

How to correctly redirect after catching authentication failure with Apollo and React

痴心易碎 提交于 2021-01-02 05:22:17
问题 I'm writing a react app that uses apollo-client and I'm using apollo-link-error to catch authentication errors globally. I'm using createBrowserHistory for browser history manipulation and redux to manage my app state. On authentication error I want to redirect the user to the /login page. However, doing so with history.push('/login') and forceRefresh:false changes the URL but doesn't actually navigate inside my app. If I use forceRefresh:true it works, but the app is completely restarted,