Skip to content

Commit

Permalink
Make storefrontApiVersion optional (#984)
Browse files Browse the repository at this point in the history
* Make storefrontApiVersion optional and remove it by default in examples

* Changesets
  • Loading branch information
frandiox committed Jun 7, 2023
1 parent d8c905c commit 442f602
Show file tree
Hide file tree
Showing 23 changed files with 9 additions and 25 deletions.
7 changes: 7 additions & 0 deletions .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.
1 change: 0 additions & 1 deletion 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"
1 change: 0 additions & 1 deletion examples/express/remix.env.d.ts
Expand Up @@ -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;
};
Expand Down
1 change: 0 additions & 1 deletion examples/express/server.js
Expand Up @@ -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'),
Expand Down
Expand Up @@ -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,
});
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions packages/hydrogen-react/src/storefront-client.ts
Expand Up @@ -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"`
*
Expand All @@ -29,7 +29,7 @@ export function createStorefrontClient(
storeDomain,
privateStorefrontToken,
publicStorefrontToken,
storefrontApiVersion,
storefrontApiVersion = SFAPI_VERSION,
contentType,
} = props;

Expand Down
Expand Up @@ -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"
1 change: 0 additions & 1 deletion packages/hydrogen/docs/staticPages/authenticate.server.js
Expand Up @@ -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),
});
1 change: 0 additions & 1 deletion packages/hydrogen/hydrogen.config.d.ts
Expand Up @@ -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;
}
Expand Down
Expand Up @@ -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),
});
Expand Down
Expand Up @@ -12,7 +12,6 @@ export default {
waitUntil: (p: Promise<unknown>) => 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),
});
Expand Down
2 changes: 0 additions & 2 deletions packages/hydrogen/src/storefrontClient.example.js
Expand Up @@ -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}`,
/**
Expand Down
2 changes: 0 additions & 2 deletions packages/hydrogen/src/storefrontClient.example.ts
Expand Up @@ -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}`,
/**
Expand Down
1 change: 0 additions & 1 deletion templates/demo-store/.env
Expand Up @@ -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"
1 change: 0 additions & 1 deletion templates/demo-store/remix.env.d.ts
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion templates/demo-store/server.ts
Expand Up @@ -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),
});
Expand Down
1 change: 0 additions & 1 deletion templates/hello-world/.env
Expand Up @@ -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"
1 change: 0 additions & 1 deletion templates/hello-world/remix.env.d.ts
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion templates/hello-world/server.ts
Expand Up @@ -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),
});
Expand Down
1 change: 0 additions & 1 deletion templates/skeleton/.env
Expand Up @@ -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"
1 change: 0 additions & 1 deletion templates/skeleton/remix.env.d.ts
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion templates/skeleton/server.ts
Expand Up @@ -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),
});
Expand Down

0 comments on commit 442f602

Please sign in to comment.