From 1875bf6c6905ead598ee129b7da405fb5be237a7 Mon Sep 17 00:00:00 2001 From: Alexandra Goff Date: Wed, 2 Oct 2024 13:38:41 -0700 Subject: [PATCH] chore(debug): change process code for debug --- lib/api/client/query.ts | 33 ++++++++++++++------------------- lib/fetch.js | 2 +- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/lib/api/client/query.ts b/lib/api/client/query.ts index 84b13dd0..fa577dad 100644 --- a/lib/api/client/query.ts +++ b/lib/api/client/query.ts @@ -15,6 +15,15 @@ if ( API_URL = `http://${process.env.DOCKER_GATEWAY_IP}:${process.env.DOCKER_GATEWAY_PORT}/api`; } +const makeClient = () => { + return createClient({ + url: API_URL, + exchanges: [cacheExchange, fetchExchange], + }); +}; + +const { getClient } = registerUrql(makeClient); + const queryAPI = async ({ query, variables, @@ -30,24 +39,6 @@ const queryAPI = async ({ params.append("token", previewToken); } - const makeClient = () => { - return createClient({ - url: `${API_URL}?${params.toString()}`, - exchanges: [cacheExchange, fetchExchange], - fetchOptions: () => { - return { - next: { - revalidate: previewToken ? 0 : undefined, - }, - }; - }, - }); - }; - - const { getClient } = registerUrql(makeClient); - - console.info("urql query"); - return await getClient() .query(query, variables) .toPromise() @@ -58,7 +49,11 @@ const queryAPI = async ({ // TODO: refresh token & rerun request if expired token error if (result.error.networkError) { - process.exitCode = 1; + process.exitCode = -99; // so we can confirm that the exit code as seen in ArgoCD is coming from this line + console.info(result.error); + } else if (result.error) { + console.info("Some other error occurred!"); + console.info(result.error); } } diff --git a/lib/fetch.js b/lib/fetch.js index 2246cea7..3d40d708 100644 --- a/lib/fetch.js +++ b/lib/fetch.js @@ -26,7 +26,7 @@ export async function queryAPI(query, token, previewToken, variables = {}) { .request(query, variables, headers) .then((data) => data) .catch((error) => { - process.exitCode = 1; + process.exitCode = -99; console.warn("Error in fetch.js :"); console.warn(error); return error.response;