From 9cfc6a3f7ba2baa8a525afcd77504ef508b76acb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 04:49:27 +0000 Subject: [PATCH 1/3] Initial plan From de108bff144e0c8454d6522da8bab272440e4050 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 04:57:32 +0000 Subject: [PATCH 2/3] Update generate script to support fallback endpoint when env vars missing Co-authored-by: bookernath <8922457+bookernath@users.noreply.github.com> --- core/scripts/generate.cjs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/core/scripts/generate.cjs b/core/scripts/generate.cjs index 0af8f38050..f65b6273b1 100644 --- a/core/scripts/generate.cjs +++ b/core/scripts/generate.cjs @@ -7,11 +7,7 @@ const graphqlApiDomain = process.env.BIGCOMMERCE_GRAPHQL_API_DOMAIN ?? 'mybigcom const getStoreHash = () => { const storeHash = process.env.BIGCOMMERCE_STORE_HASH; - if (!storeHash) { - throw new Error('Missing store hash'); - } - - return storeHash; + return storeHash || null; }; const getChannelId = () => { @@ -23,17 +19,18 @@ const getChannelId = () => { const getToken = () => { const token = process.env.BIGCOMMERCE_STOREFRONT_TOKEN; - if (!token) { - throw new Error('Missing storefront token'); - } - - return token; + return token || null; }; const getEndpoint = () => { const storeHash = getStoreHash(); const channelId = getChannelId(); + // If no store hash is available, use the public fallback endpoint + if (!storeHash) { + return 'https://cxm-prd.bigcommerceapp.com/api/graphql-schema'; + } + // Not all sites have the channel-specific canonical URL backfilled. // Wait till MSF-2643 is resolved before removing and simplifying the endpoint logic. if (!channelId || channelId === '1') { @@ -45,9 +42,15 @@ const getEndpoint = () => { const generate = async () => { try { + const endpoint = getEndpoint(); + const token = getToken(); + + // Only include authorization header if we have a token (i.e., not using fallback endpoint) + const headers = token ? { Authorization: `Bearer ${token}` } : {}; + await generateSchema({ - input: getEndpoint(), - headers: { Authorization: `Bearer ${getToken()}` }, + input: endpoint, + headers, output: join(__dirname, '../bigcommerce.graphql'), tsconfig: undefined, }); From a8963bd6ec700a65d71f01bccabdd4d046c813a0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 24 Aug 2025 05:13:43 +0000 Subject: [PATCH 3/3] Fix prettier formatting issues in generate.cjs Co-authored-by: bookernath <8922457+bookernath@users.noreply.github.com> --- core/scripts/generate.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/scripts/generate.cjs b/core/scripts/generate.cjs index f65b6273b1..36d303773b 100644 --- a/core/scripts/generate.cjs +++ b/core/scripts/generate.cjs @@ -44,10 +44,10 @@ const generate = async () => { try { const endpoint = getEndpoint(); const token = getToken(); - + // Only include authorization header if we have a token (i.e., not using fallback endpoint) const headers = token ? { Authorization: `Bearer ${token}` } : {}; - + await generateSchema({ input: endpoint, headers,