-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fresh_graphql] shouldRefresh example needed #81
Comments
shouldRefresh: (_) {
print("SHOULD REFRESH TOKEN?");
if (token == null || token == '') {
print("SHOULD REFRESH TOKEN? 2");
return true;
} else {
if (JwtDecoder.isExpired(token ?? '')) {
print("TOKEN IS EXPIRED");
return true;
} else {
print("TOKEN IS NOT EXPIRED");
return false;
}
}
}, |
Here is JwtDecoder. |
Can you provide it in pub.dev example for other people? the example is useful and would definitely benefit others |
That's how it's implemented in my project. shouldRefresh: (response) {
final errors = response.errors;
return errors != null &&
errors.isNotEmpty &&
errors.firstWhereOrNull((e) => e.extensions?['code'] == GraphqlErrorCodes.eTokenInactive) != null;
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can't figure out how to implement a
shouldRefresh
condition.shouldRefresh: (response) => response.errors... // somehow check if a token is stale ?
The text was updated successfully, but these errors were encountered: