@graphcommerce/algolia-products 10.0.1-canary.0 → 10.0.1-canary.2

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @graphcommerce/algolia-products
2
2
 
3
+ ## 10.0.1-canary.2
4
+
5
+ ## 10.0.1-canary.1
6
+
7
+ ### Patch Changes
8
+
9
+ - [#2571](https://github.com/graphcommerce-org/graphcommerce/pull/2571) [`591fb82`](https://github.com/graphcommerce-org/graphcommerce/commit/591fb827b2db87dd138cf05e443089355e8883d1) - Make sure the default_display_currency_code is always fetched properly for Algolia ([@paales](https://github.com/paales))
10
+
3
11
  ## 10.0.1-canary.0
4
12
 
5
13
  ### Patch Changes
@@ -81,7 +81,10 @@ export function algoliaFacetsToAggregations(
81
81
  categoryList?: null | CategoryResult,
82
82
  groupId?: number,
83
83
  ): Aggregation[] {
84
- if (!storeConfig?.default_display_currency_code) throw new Error('Currency is required')
84
+ if (!storeConfig?.default_display_currency_code)
85
+ throw new Error(
86
+ `Currency is required. StoreConfig default_display_currency_code is not set. This usually means the storeConfig query failed or the store doesn't have a default currency configured.`,
87
+ )
85
88
  const aggregations: Aggregation[] = []
86
89
 
87
90
  if (!assertAlgoliaFacets(algoliaFacets)) throw Error('these are not facets')
@@ -35,7 +35,10 @@ function mapPriceRange(
35
35
  customerGroup = 0,
36
36
  currencyHeader?: string,
37
37
  ): PriceRange {
38
- if (!storeConfig?.default_display_currency_code) throw new Error('Currency is required')
38
+ if (!storeConfig?.default_display_currency_code)
39
+ throw new Error(
40
+ `Currency is required. StoreConfig default_display_currency_code is not set. This usually means the storeConfig query failed or the store doesn't have a default currency configured.`,
41
+ )
39
42
 
40
43
  const curr = currencyHeader ?? storeConfig.default_display_currency_code
41
44
 
@@ -1,6 +1,11 @@
1
1
  import type { Maybe, MeshContext, StoreConfig } from '@graphcommerce/graphql-mesh'
2
+ import { storefrontConfigDefault } from '@graphcommerce/next-ui'
2
3
  import { getIndexName } from './getIndexName'
3
4
 
5
+ function getStoreHeader(context: MeshContext) {
6
+ return (context as MeshContext & { headers: Record<string, string | undefined> }).headers?.store
7
+ }
8
+
4
9
  export type GetStoreConfigReturn =
5
10
  | Maybe<
6
11
  Pick<
@@ -18,8 +23,13 @@ export async function getStoreConfig(context: MeshContext): Promise<StoreConfig>
18
23
  const configCached = context.cache.get(cacheKey)
19
24
  if (configCached) return configCached as StoreConfig
20
25
 
26
+ // Ensure we have a store header set for the storeConfig query
27
+ const storeCode = getStoreHeader(context) ?? storefrontConfigDefault().magentoStoreCode
28
+ const contextWithHeaders = context as MeshContext & { headers?: Record<string, string> }
29
+ const storeContext = { ...context, headers: { ...contextWithHeaders.headers, store: storeCode } }
30
+
21
31
  const configCache = await context.m2.Query.storeConfig({
22
- context,
32
+ context: storeContext,
23
33
  selectionSet: /* GraphQL */ `
24
34
  {
25
35
  root_category_uid
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/algolia-products",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "10.0.1-canary.0",
5
+ "version": "10.0.1-canary.2",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -15,14 +15,14 @@
15
15
  "generate": "tsx scripts/generate-spec.mts"
16
16
  },
17
17
  "peerDependencies": {
18
- "@graphcommerce/google-datalayer": "^10.0.1-canary.0",
19
- "@graphcommerce/graphql": "^10.0.1-canary.0",
20
- "@graphcommerce/graphql-mesh": "^10.0.1-canary.0",
21
- "@graphcommerce/magento-customer": "^10.0.1-canary.0",
22
- "@graphcommerce/magento-product": "^10.0.1-canary.0",
23
- "@graphcommerce/magento-search": "^10.0.1-canary.0",
24
- "@graphcommerce/next-config": "^10.0.1-canary.0",
25
- "@graphcommerce/next-ui": "^10.0.1-canary.0",
18
+ "@graphcommerce/google-datalayer": "^10.0.1-canary.2",
19
+ "@graphcommerce/graphql": "^10.0.1-canary.2",
20
+ "@graphcommerce/graphql-mesh": "^10.0.1-canary.2",
21
+ "@graphcommerce/magento-customer": "^10.0.1-canary.2",
22
+ "@graphcommerce/magento-product": "^10.0.1-canary.2",
23
+ "@graphcommerce/magento-search": "^10.0.1-canary.2",
24
+ "@graphcommerce/next-config": "^10.0.1-canary.2",
25
+ "@graphcommerce/next-ui": "^10.0.1-canary.2",
26
26
  "react": "^19.2.0"
27
27
  },
28
28
  "devDependencies": {