IO-1162 Retry query on JWT expiration

This commit is contained in:
Patrick Fic
2021-05-26 10:30:52 -07:00
parent 0ab4cc38d0
commit bfa68858e5

View File

@@ -22,7 +22,7 @@ namespace BodyshopPartner.Utils
return graphQLClient; return graphQLClient;
} }
public static async Task<dynamic> ExecuteQuery(GraphQLRequest r) public static async Task<dynamic> ExecuteQuery(GraphQLRequest r, bool lastTry = false)
{ {
using (var g = Utils.GraphQL.CreateGQLClient()) using (var g = Utils.GraphQL.CreateGQLClient())
{ {
@@ -49,9 +49,15 @@ namespace BodyshopPartner.Utils
}; };
exceptionString = exceptionString + x + ";"; exceptionString = exceptionString + x + ";";
}); });
if (jwtExpired) await Utils.Auth.Refresh(); ; if (jwtExpired && !lastTry) { await Utils.Auth.Refresh();
logger.Error("---------------------"); return (ExecuteQuery(r, true));
throw new Exception(exceptionString); }
else
{
logger.Error("---------------------");
throw new Exception(exceptionString);
}
} }
} }
} }