Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/breadcrumb-up-locale-race.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/demo-magento-graphcommerce': patch
---

Fix breadcrumb "up" link title being translated in the wrong locale during static generation. The Lingui `t` macro title was evaluated inside the returned props after awaiting GraphQL queries, so a concurrent static-generation request for another locale could change the global active locale mid-flight. The `up` object is now computed synchronously before any await, capturing the correct locale for the current request.
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default RouteNotFoundPage

export const getStaticProps: GetPageStaticProps = async (context) => {
const client = graphqlSharedClient(context)
const up = { href: '/', title: t`Home` }
const staticClient = graphqlSsrClient(context)
const conf = client.query({ query: StoreConfigDocument })
const layout = staticClient.query({
Expand All @@ -85,7 +86,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
return {
props: {
...(await layout).data,
up: { href: '/', title: t`Home` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
revalidate: revalidate(),
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/[...url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (!url || !query) return { notFound: true, revalidate: revalidate() }

const client = graphqlSharedClient(context)
const homeUp = { href: '/', title: t`Home` }
const conf = client.query({ query: StoreConfigDocument })
const filterTypes = getFilterTypes(client)

Expand Down Expand Up @@ -259,7 +260,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
const up =
category_url_path && category_name
? { href: `/${category_url_path}`, title: category_name }
: { href: '/', title: t`Home` }
: homeUp

await waitForSiblings
const result = {
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/addresses/add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/addresses/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/addresses', title: t`Addresses` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/addresses', title: t`Addresses` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/addresses/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const staticClient = graphqlSsrClient(context)
const conf = client.query({ query: StoreConfigDocument })

Expand All @@ -76,7 +77,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...(await countryRegions).data,
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/contact/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/forgot-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/signin', title: t`Sign in` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/signin', title: t`Sign in` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {

const staticClient = graphqlSsrClient(context)
const client = graphqlSharedClient(context)
const up = { href: '/', title: t`Home` }
const conf = client.query({ query: StoreConfigDocument })
const layout = staticClient.query({
query: LayoutDocument,
Expand All @@ -164,7 +165,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
return {
props: {
...(await layout).data,
up: { href: '/', title: t`Home` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
revalidate: revalidate(),
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/name/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

if (magentoVersion >= 247) await preloadAttributesForm(client, 'customer_account_edit')
Expand All @@ -85,7 +86,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/orders', title: t`Orders` }
const staticClient = graphqlSsrClient(context)
const config = client.query({ query: StoreConfigDocument })

Expand All @@ -111,7 +112,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...(await countryRegions).data,
apolloState: await config.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/orders', title: t`Orders` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/orders/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account', title: t`Account` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/orders/invoice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/orders', title: t`Orders` }
const staticClient = graphqlSsrClient(context)
const config = client.query({ query: StoreConfigDocument })

Expand All @@ -108,7 +109,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...(await countryRegions).data,
apolloState: await config.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/orders', title: t`Orders` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/orders/shipment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/orders', title: t`Orders` }
const staticClient = graphqlSsrClient(context)
const config = client.query({ query: StoreConfigDocument })

Expand All @@ -108,7 +109,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...(await countryRegions).data,
apolloState: await config.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/orders', title: t`Orders` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/orders/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/orders', title: t`Orders` }
const staticClient = graphqlSsrClient(context)
const config = client.query({ query: StoreConfigDocument })

Expand All @@ -107,7 +108,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...(await countryRegions).data,
apolloState: await config.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/orders', title: t`Orders` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/account/reviews/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account', title: t`Account` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
up: { href: '/account', title: t`Account` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/blog/[...url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
const urlKey = params?.url.join('/') ?? ''

const client = graphqlSharedClient(context)
const up = { href: '/blog', title: t`Blog` }
const staticClient = graphqlSsrClient(context)
const limit = 4
const conf = client.query({ query: StoreConfigDocument })
Expand All @@ -131,7 +132,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...pageData,
...blogPostsData,
...(await layout).data,
up: { href: '/blog', title: t`Blog` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
revalidate: revalidate(),
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/blog/tagged/[url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
const { locale, params } = context
const urlKey = params?.url ?? '??'
const client = graphqlSharedClient(context)
const up = { href: '/blog', title: t`Blog` }
const staticClient = graphqlSsrClient(context)
const limit = 99
const conf = client.query({ query: StoreConfigDocument })
Expand All @@ -106,7 +107,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
...pageData.data,
...posts.data,
...(await layout).data,
up: { href: '/blog', title: t`Blog` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
revalidate: revalidate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCartDisabled(context.locale) || getCustomerAccountIsDisabled(context.locale))
return { notFound: true }
const client = graphqlSharedClient(context)
const up = { href: '/checkout', title: t`Shipping` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/checkout', title: t`Shipping` },
up,
},
}
}
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/checkout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCheckoutIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/cart', title: t`Cart` }
const conf = client.query({ query: StoreConfigDocument })
const staticClient = graphqlSsrClient(context)

Expand All @@ -165,7 +166,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
return {
props: {
...(await layout).data,
up: { href: '/cart', title: t`Cart` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
}
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/checkout/payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCheckoutIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/checkout', title: t`Shipping` }
const staticClient = graphqlSsrClient(context)

const conf = client.query({ query: StoreConfigDocument })
Expand All @@ -169,7 +170,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
return {
props: {
...(await layout).data,
up: { href: '/checkout', title: t`Shipping` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
}
Expand Down
3 changes: 2 additions & 1 deletion examples/magento-graphcms/pages/checkout/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default OrderSuccessPage
export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCheckoutIsDisabled(context.locale)) return { notFound: true }
const client = graphqlSharedClient(context)
const up = { href: '/', title: t`Home` }
const staticClient = graphqlSsrClient(context)
const conf = client.query({ query: StoreConfigDocument })
const layout = staticClient.query({
Expand All @@ -112,7 +113,7 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
return {
props: {
...(await layout).data,
up: { href: '/', title: t`Home` },
up,
apolloState: await conf.then(() => client.cache.extract()),
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ export const getStaticProps: GetPageStaticProps = async (context) => {
if (getCustomerAccountIsDisabled(context.locale)) return { notFound: true }

const client = graphqlSharedClient(context)
const up = { href: '/account/signin', title: t`Sign in` }
const conf = client.query({ query: StoreConfigDocument })

return {
props: {
apolloState: await conf.then(() => client.cache.extract()),
variantMd: 'bottom',
up: { href: '/account/signin', title: t`Sign in` },
up,
},
}
}
Loading
Loading