Hi there! This is by far the most intuitive package for refreshing tokens in graphql. Here is one enhancement that I would like to see:
in a case like this:
refreshToken: (token, client) async {
await tokenManager.refresh();
}
if there is an error in refreshing the token, it is not possible to get it to the client; any thrown error here is "swallowed". If the api looked something like this:
refreshToken: (token, client, resp) async {
await tokenManager.refresh();
}
then you could do something like:
refreshToken: (token, client, resp) async {
try {
await tokenManager.refresh();
} catch {
resp.errors.add(GraphQLError(message: 'Error refreshing access tokens`));
}
}
and then it would be easy to log the user out or similar in a situation like this. Right now, I'm just assuming if response.hasErrors && response.errors == null then this is an error in the refresh token, which is obviously not a robust assumption (as it's possible that the response would have errors but no errors have been added for other reasons.)
I don't think it's an unfair assumption to believe that for some reason, a token refresh could fail: for instance, if a refresh token is compromised manually resetting it on the server would cause the refresh to fail; in a situation like this, I probably want to log the user out.
Thanks for the package! It helps a lot in my development.
Hi there! This is by far the most intuitive package for refreshing tokens in graphql. Here is one enhancement that I would like to see:
in a case like this:
if there is an error in refreshing the token, it is not possible to get it to the client; any thrown error here is "swallowed". If the api looked something like this:
then you could do something like:
and then it would be easy to log the user out or similar in a situation like this. Right now, I'm just assuming if
response.hasErrors && response.errors == nullthen this is an error in the refresh token, which is obviously not a robust assumption (as it's possible that the response would have errors but no errors have been added for other reasons.)I don't think it's an unfair assumption to believe that for some reason, a token refresh could fail: for instance, if a refresh token is compromised manually resetting it on the server would cause the refresh to fail; in a situation like this, I probably want to log the user out.
Thanks for the package! It helps a lot in my development.