@graphcommerce/magento-store 9.1.0-canary.50 → 9.1.0-canary.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/index.ts +1 -0
- package/package.json +10 -10
- package/plugins/magentoCurrencyCode.ts +12 -0
- package/utils/storefrontFromContext.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.1.0-canary.51
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2537](https://github.com/graphcommerce-org/graphcommerce/pull/2537) [`958dcb6`](https://github.com/graphcommerce-org/graphcommerce/commit/958dcb62d5abb3427a38e2a4583897f3e2043cc4) - Intoduce a new Product-`uid` to solve an issue where cache normalization was not working properly on the frontend when viewing products with a differen curreny, etc.
|
|
8
|
+
|
|
9
|
+
Products now have a more detailed `uid` which will include the scope the product is retrieved from. For example: `NDg5MDM=?store=nl_NL¤cyCode=EUR`. This results in a better cache normalization in Apollo Client and allows for switching between scopes (store/currency/price views/accounts) without creating a broken cache state.
|
|
10
|
+
|
|
11
|
+
We have implemented this with a new resolver that rewrites the `uid` passed from Magento to the Mesh Resolver, and additing additonal data to the `uid` based on the headers passed from the client. This also requires each package to implement the `getPrivateQueryContextMesh` method to retrieve the current PrivateQuery context from the GraphQL request headers. ([@paales](https://github.com/paales))
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#2537](https://github.com/graphcommerce-org/graphcommerce/pull/2537) [`31397f9`](https://github.com/graphcommerce-org/graphcommerce/commit/31397f9c5b2d85895d6e00732b2e3d7a99ffee53) - Solve issue where a magento store reference was added to the graphql-mesh package. ([@paales](https://github.com/paales))
|
|
16
|
+
|
|
3
17
|
## 9.1.0-canary.50
|
|
4
18
|
|
|
5
19
|
## 9.1.0-canary.49
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-store",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.1.0-canary.
|
|
5
|
+
"version": "9.1.0-canary.51",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,15 +12,15 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.
|
|
17
|
-
"@graphcommerce/framer-utils": "^9.1.0-canary.
|
|
18
|
-
"@graphcommerce/graphql": "^9.1.0-canary.
|
|
19
|
-
"@graphcommerce/graphql-mesh": "^9.1.0-canary.
|
|
20
|
-
"@graphcommerce/image": "^9.1.0-canary.
|
|
21
|
-
"@graphcommerce/next-ui": "^9.1.0-canary.
|
|
22
|
-
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.
|
|
23
|
-
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^9.1.0-canary.51",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^9.1.0-canary.51",
|
|
17
|
+
"@graphcommerce/framer-utils": "^9.1.0-canary.51",
|
|
18
|
+
"@graphcommerce/graphql": "^9.1.0-canary.51",
|
|
19
|
+
"@graphcommerce/graphql-mesh": "^9.1.0-canary.51",
|
|
20
|
+
"@graphcommerce/image": "^9.1.0-canary.51",
|
|
21
|
+
"@graphcommerce/next-ui": "^9.1.0-canary.51",
|
|
22
|
+
"@graphcommerce/prettier-config-pwa": "^9.1.0-canary.51",
|
|
23
|
+
"@graphcommerce/typescript-config-pwa": "^9.1.0-canary.51",
|
|
24
24
|
"@lingui/core": "^4.2.1",
|
|
25
25
|
"@lingui/macro": "^4.2.1",
|
|
26
26
|
"@lingui/react": "^4.2.1",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type getPrivateQueryContextMesh as getPrivateQueryContextMeshType,
|
|
2
3
|
type getPrivateQueryContext as getPrivateQueryContextType,
|
|
3
4
|
type usePrivateQueryContext as usePrivateQueryContextType,
|
|
4
5
|
} from '@graphcommerce/graphql'
|
|
@@ -12,6 +13,17 @@ export const config: PluginConfig = {
|
|
|
12
13
|
module: '@graphcommerce/graphql',
|
|
13
14
|
}
|
|
14
15
|
|
|
16
|
+
export const getPrivateQueryContextMesh: FunctionPlugin<typeof getPrivateQueryContextMeshType> = (
|
|
17
|
+
prev,
|
|
18
|
+
context,
|
|
19
|
+
) => {
|
|
20
|
+
const currencyCode = context.headers?.['content-currency']
|
|
21
|
+
|
|
22
|
+
const res = prev(context)
|
|
23
|
+
if (!currencyCode) return res
|
|
24
|
+
return { ...res, currencyCode } satisfies PrivateContext
|
|
25
|
+
}
|
|
26
|
+
|
|
15
27
|
export const getPrivateQueryContext: FunctionPlugin<typeof getPrivateQueryContextType> = (
|
|
16
28
|
prev,
|
|
17
29
|
client,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MeshContext } from '@graphcommerce/graphql-mesh'
|
|
2
|
+
import type { GraphCommerceStorefrontConfig } from '@graphcommerce/next-config'
|
|
3
|
+
|
|
4
|
+
export function storefrontFromContext(
|
|
5
|
+
context: MeshContext & { headers?: Record<string, string> },
|
|
6
|
+
): GraphCommerceStorefrontConfig | undefined {
|
|
7
|
+
const storefrontAll = import.meta.graphCommerce.storefront
|
|
8
|
+
const store = context.headers?.store
|
|
9
|
+
return storefrontAll.find((s) => s.magentoStoreCode === store)
|
|
10
|
+
}
|