felangel / fresh

🍋 A token refresh library for Dart.
https://github.com/felangel/fresh
360 stars 57 forks source link

fix(fresh_graphql): should refresh before forwarding request #109

Open zhaoterryy opened 1 week ago

zhaoterryy commented 1 week ago

Thanks for the package @felangel!

Using fresh_graphql + ferry I noticed that the access token never refreshes if it had already expired. This seems to be happening due to forward() being called before the refresh logic happens (_shouldRefresh()). Ultimately this means that if the user steps away and the token expires, it never gets refreshed.

These changes seem to work fine with ferry but I'm happy to make changes as needed for other graphql clients.