From 442f602a45902beeb188575a85151f45b8be23ca Mon Sep 17 00:00:00 2001 From: Fran Dios Date: Wed, 7 Jun 2023 09:59:57 +0900 Subject: [PATCH] Make `storefrontApiVersion` optional (#984) * Make storefrontApiVersion optional and remove it by default in examples * Changesets --- .changeset/mean-balloons-lick.md | 7 +++++++ examples/express/.env | 1 - examples/express/remix.env.d.ts | 1 - examples/express/server.js | 1 - .../hydrogen-react/docs/staticPages/authenticate.client.js | 1 - .../docs/staticPages/authenticate.env.example | 1 - packages/hydrogen-react/src/storefront-client.ts | 4 ++-- .../hydrogen/docs/staticPages/authenticate.env.example | 1 - packages/hydrogen/docs/staticPages/authenticate.server.js | 1 - packages/hydrogen/hydrogen.config.d.ts | 1 - .../hydrogen/src/routing/storefrontRedirect.example.js | 1 - .../hydrogen/src/routing/storefrontRedirect.example.ts | 1 - packages/hydrogen/src/storefrontClient.example.js | 2 -- packages/hydrogen/src/storefrontClient.example.ts | 2 -- templates/demo-store/.env | 1 - templates/demo-store/remix.env.d.ts | 1 - templates/demo-store/server.ts | 1 - templates/hello-world/.env | 1 - templates/hello-world/remix.env.d.ts | 1 - templates/hello-world/server.ts | 1 - templates/skeleton/.env | 1 - templates/skeleton/remix.env.d.ts | 1 - templates/skeleton/server.ts | 1 - 23 files changed, 9 insertions(+), 25 deletions(-) create mode 100644 .changeset/mean-balloons-lick.md diff --git a/.changeset/mean-balloons-lick.md b/.changeset/mean-balloons-lick.md new file mode 100644 index 0000000000..42232c0e0f --- /dev/null +++ b/.changeset/mean-balloons-lick.md @@ -0,0 +1,7 @@ +--- +'@shopify/hydrogen-react': patch +'@shopify/hydrogen': patch +'demo-store': patch +--- + +Make `storefrontApiVersion` parameter optional. By default, it will use the current version of Hydrogen as the Storefront API version. diff --git a/examples/express/.env b/examples/express/.env index a651416579..f270447b8f 100644 --- a/examples/express/.env +++ b/examples/express/.env @@ -1,4 +1,3 @@ SESSION_SECRET="foobar" PUBLIC_STOREFRONT_API_TOKEN="3b580e70970c4528da70c98e097c2fa0" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="hydrogen-preview.myshopify.com" diff --git a/examples/express/remix.env.d.ts b/examples/express/remix.env.d.ts index aa21e01b10..f3bd4f61d2 100644 --- a/examples/express/remix.env.d.ts +++ b/examples/express/remix.env.d.ts @@ -21,7 +21,6 @@ declare module '@remix-run/node' { SESSION_SECRET: string; PUBLIC_STOREFRONT_API_TOKEN: string; PRIVATE_STOREFRONT_API_TOKEN: string; - PUBLIC_STOREFRONT_API_VERSION: string; PUBLIC_STORE_DOMAIN: string; PUBLIC_STOREFRONT_ID: string; }; diff --git a/examples/express/server.js b/examples/express/server.js index 2e510f59a7..cb948c2b43 100644 --- a/examples/express/server.js +++ b/examples/express/server.js @@ -88,7 +88,6 @@ async function getContext(req) { publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-04', storefrontId: env.PUBLIC_STOREFRONT_ID, storefrontHeaders: { requestGroupId: req.get('request-id'), diff --git a/packages/hydrogen-react/docs/staticPages/authenticate.client.js b/packages/hydrogen-react/docs/staticPages/authenticate.client.js index 5aab76560f..340aa93c56 100644 --- a/packages/hydrogen-react/docs/staticPages/authenticate.client.js +++ b/packages/hydrogen-react/docs/staticPages/authenticate.client.js @@ -3,6 +3,5 @@ import {createStorefrontClient} from '@shopify/hydrogen-react'; export const client = createStorefrontClient({ // load environment variables according to your framework and runtime storeDomain: process.env.PUBLIC_STORE_DOMAIN, - storefrontApiVersion: process.env.PUBLIC_STOREFRONT_API_VERSION, publicStorefrontToken: process.env.PUBLIC_STOREFRONT_API_TOKEN, }); diff --git a/packages/hydrogen-react/docs/staticPages/authenticate.env.example b/packages/hydrogen-react/docs/staticPages/authenticate.env.example index 004216fda0..ca7216fe44 100644 --- a/packages/hydrogen-react/docs/staticPages/authenticate.env.example +++ b/packages/hydrogen-react/docs/staticPages/authenticate.env.example @@ -2,5 +2,4 @@ PUBLIC_STOREFRONT_API_TOKEN="public_token" PRIVATE_STOREFRONT_API_TOKEN="private_token" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="store_id.myshopify.com" diff --git a/packages/hydrogen-react/src/storefront-client.ts b/packages/hydrogen-react/src/storefront-client.ts index 7914681188..7182dcc830 100644 --- a/packages/hydrogen-react/src/storefront-client.ts +++ b/packages/hydrogen-react/src/storefront-client.ts @@ -8,7 +8,7 @@ export type StorefrontClientProps = { /** The Storefront API access token. Refer to the [authentication](https://shopify.dev/api/storefront#authentication) documentation for more details. */ publicStorefrontToken?: string; /** The Storefront API version. This should almost always be the same as the version Hydrogen React was built for. Learn more about Shopify [API versioning](https://shopify.dev/api/usage/versioning) for more details. */ - storefrontApiVersion: string; + storefrontApiVersion?: string; /** * Customizes which `"content-type"` header is added when using `getPrivateTokenHeaders()` and `getPublicTokenHeaders()`. When fetching with a `JSON.stringify()`-ed `body`, use `"json"`. When fetching with a `body` that is a plain string, use `"graphql"`. Defaults to `"json"` * @@ -29,7 +29,7 @@ export function createStorefrontClient( storeDomain, privateStorefrontToken, publicStorefrontToken, - storefrontApiVersion, + storefrontApiVersion = SFAPI_VERSION, contentType, } = props; diff --git a/packages/hydrogen/docs/staticPages/authenticate.env.example b/packages/hydrogen/docs/staticPages/authenticate.env.example index 266c1ee5cd..206ac80541 100644 --- a/packages/hydrogen/docs/staticPages/authenticate.env.example +++ b/packages/hydrogen/docs/staticPages/authenticate.env.example @@ -5,5 +5,4 @@ SESSION_SECRET="foobar" PUBLIC_STOREFRONT_API_TOKEN="3b580e70970c4528da70c98e097c2fa0" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="hydrogen-preview.myshopify.com" diff --git a/packages/hydrogen/docs/staticPages/authenticate.server.js b/packages/hydrogen/docs/staticPages/authenticate.server.js index 26870e64d5..590cf609dd 100644 --- a/packages/hydrogen/docs/staticPages/authenticate.server.js +++ b/packages/hydrogen/docs/staticPages/authenticate.server.js @@ -16,7 +16,6 @@ const {storefront} = createStorefrontClient({ publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-04', storefrontId: env.PUBLIC_STOREFRONT_ID, storefrontHeaders: getStorefrontHeaders(request), }); diff --git a/packages/hydrogen/hydrogen.config.d.ts b/packages/hydrogen/hydrogen.config.d.ts index eed8d53b3f..15a971156c 100644 --- a/packages/hydrogen/hydrogen.config.d.ts +++ b/packages/hydrogen/hydrogen.config.d.ts @@ -13,7 +13,6 @@ declare global { SESSION_SECRET: string; PUBLIC_STOREFRONT_API_TOKEN: string; PRIVATE_STOREFRONT_API_TOKEN: string; - PUBLIC_STOREFRONT_API_VERSION: string; PUBLIC_STORE_DOMAIN: string; PUBLIC_STOREFRONT_ID: string; } diff --git a/packages/hydrogen/src/routing/storefrontRedirect.example.js b/packages/hydrogen/src/routing/storefrontRedirect.example.js index 4e2cc8e1a0..4547b548ca 100644 --- a/packages/hydrogen/src/routing/storefrontRedirect.example.js +++ b/packages/hydrogen/src/routing/storefrontRedirect.example.js @@ -12,7 +12,6 @@ export default { waitUntil: (p) => executionContext.waitUntil(p), privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, storefrontHeaders: getStorefrontHeaders(request), }); diff --git a/packages/hydrogen/src/routing/storefrontRedirect.example.ts b/packages/hydrogen/src/routing/storefrontRedirect.example.ts index 352cdedfed..9b782c5855 100644 --- a/packages/hydrogen/src/routing/storefrontRedirect.example.ts +++ b/packages/hydrogen/src/routing/storefrontRedirect.example.ts @@ -12,7 +12,6 @@ export default { waitUntil: (p: Promise) => executionContext.waitUntil(p), privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, storefrontHeaders: getStorefrontHeaders(request), }); diff --git a/packages/hydrogen/src/storefrontClient.example.js b/packages/hydrogen/src/storefrontClient.example.js index 1ae38ff2d6..1fec615087 100644 --- a/packages/hydrogen/src/storefrontClient.example.js +++ b/packages/hydrogen/src/storefrontClient.example.js @@ -15,8 +15,6 @@ export default { privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, /* Public Storefront API token for your store */ publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, - /* Desired Storefront API version to use */ - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION, /* Your store domain: "https://{shop}.myshopify.com" */ storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, /** diff --git a/packages/hydrogen/src/storefrontClient.example.ts b/packages/hydrogen/src/storefrontClient.example.ts index db72d8bf01..28d30ad984 100644 --- a/packages/hydrogen/src/storefrontClient.example.ts +++ b/packages/hydrogen/src/storefrontClient.example.ts @@ -21,8 +21,6 @@ export default { privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, /* Public Storefront API token for your store */ publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, - /* Desired Storefront API version to use */ - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION, /* Your store domain: "https://{shop}.myshopify.com" */ storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, /** diff --git a/templates/demo-store/.env b/templates/demo-store/.env index 847b925293..9d6b66d51d 100644 --- a/templates/demo-store/.env +++ b/templates/demo-store/.env @@ -2,5 +2,4 @@ SESSION_SECRET="foobar" PUBLIC_STOREFRONT_API_TOKEN="3b580e70970c4528da70c98e097c2fa0" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="hydrogen-preview.myshopify.com" diff --git a/templates/demo-store/remix.env.d.ts b/templates/demo-store/remix.env.d.ts index e2ff23438e..989e73ab25 100644 --- a/templates/demo-store/remix.env.d.ts +++ b/templates/demo-store/remix.env.d.ts @@ -19,7 +19,6 @@ declare global { SESSION_SECRET: string; PUBLIC_STOREFRONT_API_TOKEN: string; PRIVATE_STOREFRONT_API_TOKEN: string; - PUBLIC_STOREFRONT_API_VERSION: string; PUBLIC_STORE_DOMAIN: string; PUBLIC_STOREFRONT_ID: string; } diff --git a/templates/demo-store/server.ts b/templates/demo-store/server.ts index 94f4889ac0..6f2a6d6634 100644 --- a/templates/demo-store/server.ts +++ b/templates/demo-store/server.ts @@ -42,7 +42,6 @@ export default { publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-04', storefrontId: env.PUBLIC_STOREFRONT_ID, storefrontHeaders: getStorefrontHeaders(request), }); diff --git a/templates/hello-world/.env b/templates/hello-world/.env index 847b925293..9d6b66d51d 100644 --- a/templates/hello-world/.env +++ b/templates/hello-world/.env @@ -2,5 +2,4 @@ SESSION_SECRET="foobar" PUBLIC_STOREFRONT_API_TOKEN="3b580e70970c4528da70c98e097c2fa0" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="hydrogen-preview.myshopify.com" diff --git a/templates/hello-world/remix.env.d.ts b/templates/hello-world/remix.env.d.ts index e50e90353c..bccec7ea62 100644 --- a/templates/hello-world/remix.env.d.ts +++ b/templates/hello-world/remix.env.d.ts @@ -18,7 +18,6 @@ declare global { SESSION_SECRET: string; PUBLIC_STOREFRONT_API_TOKEN: string; PRIVATE_STOREFRONT_API_TOKEN: string; - PUBLIC_STOREFRONT_API_VERSION: string; PUBLIC_STORE_DOMAIN: string; PUBLIC_STOREFRONT_ID: string; } diff --git a/templates/hello-world/server.ts b/templates/hello-world/server.ts index 71a4158ac8..ebaba5c72f 100644 --- a/templates/hello-world/server.ts +++ b/templates/hello-world/server.ts @@ -42,7 +42,6 @@ export default { publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-04', storefrontId: env.PUBLIC_STOREFRONT_ID, storefrontHeaders: getStorefrontHeaders(request), }); diff --git a/templates/skeleton/.env b/templates/skeleton/.env index 847b925293..9d6b66d51d 100644 --- a/templates/skeleton/.env +++ b/templates/skeleton/.env @@ -2,5 +2,4 @@ SESSION_SECRET="foobar" PUBLIC_STOREFRONT_API_TOKEN="3b580e70970c4528da70c98e097c2fa0" -PUBLIC_STOREFRONT_API_VERSION="2023-04" PUBLIC_STORE_DOMAIN="hydrogen-preview.myshopify.com" diff --git a/templates/skeleton/remix.env.d.ts b/templates/skeleton/remix.env.d.ts index e50e90353c..bccec7ea62 100644 --- a/templates/skeleton/remix.env.d.ts +++ b/templates/skeleton/remix.env.d.ts @@ -18,7 +18,6 @@ declare global { SESSION_SECRET: string; PUBLIC_STOREFRONT_API_TOKEN: string; PRIVATE_STOREFRONT_API_TOKEN: string; - PUBLIC_STOREFRONT_API_VERSION: string; PUBLIC_STORE_DOMAIN: string; PUBLIC_STOREFRONT_ID: string; } diff --git a/templates/skeleton/server.ts b/templates/skeleton/server.ts index 71a4158ac8..ebaba5c72f 100644 --- a/templates/skeleton/server.ts +++ b/templates/skeleton/server.ts @@ -42,7 +42,6 @@ export default { publicStorefrontToken: env.PUBLIC_STOREFRONT_API_TOKEN, privateStorefrontToken: env.PRIVATE_STOREFRONT_API_TOKEN, storeDomain: `https://${env.PUBLIC_STORE_DOMAIN}`, - storefrontApiVersion: env.PUBLIC_STOREFRONT_API_VERSION || '2023-04', storefrontId: env.PUBLIC_STOREFRONT_ID, storefrontHeaders: getStorefrontHeaders(request), });