From bfa68858e5cf73f11de29d472976dff781ee2c60 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 26 May 2021 10:30:52 -0700 Subject: [PATCH] IO-1162 Retry query on JWT expiration --- BodyshopUploader/Utils/GraphQL.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/BodyshopUploader/Utils/GraphQL.cs b/BodyshopUploader/Utils/GraphQL.cs index 573a960..ac8bb58 100644 --- a/BodyshopUploader/Utils/GraphQL.cs +++ b/BodyshopUploader/Utils/GraphQL.cs @@ -22,7 +22,7 @@ namespace BodyshopPartner.Utils return graphQLClient; } - public static async Task ExecuteQuery(GraphQLRequest r) + public static async Task ExecuteQuery(GraphQLRequest r, bool lastTry = false) { using (var g = Utils.GraphQL.CreateGQLClient()) { @@ -49,9 +49,15 @@ namespace BodyshopPartner.Utils }; exceptionString = exceptionString + x + ";"; }); - if (jwtExpired) await Utils.Auth.Refresh(); ; - logger.Error("---------------------"); - throw new Exception(exceptionString); + if (jwtExpired && !lastTry) { await Utils.Auth.Refresh(); + return (ExecuteQuery(r, true)); + } + else + { + logger.Error("---------------------"); + throw new Exception(exceptionString); + } + } } }