@graphcommerce/hygraph-ui 10.0.0-canary.68 → 10.0.0
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 +102 -0
- package/lib/getAllHygraphPages.ts +7 -5
- package/lib/getHygraphPaths.ts +8 -7
- package/lib/hygraphPageContent.ts +13 -6
- package/package.json +8 -8
- package/plugins/hygraphGraphqlConfig.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,107 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
|
|
8
|
+
|
|
9
|
+
This major release brings full Turbopack compatibility, dramatically improving development speed.
|
|
10
|
+
|
|
11
|
+
### 🚀 Turbopack-Compatible Interceptor System
|
|
12
|
+
|
|
13
|
+
The entire plugin/interceptor system has been rewritten to work with Turbopack:
|
|
14
|
+
|
|
15
|
+
- **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
|
|
16
|
+
- **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
|
|
17
|
+
- **Direct imports** - Interceptors import from `.original` files instead of embedding source
|
|
18
|
+
- **New CLI commands**:
|
|
19
|
+
- `graphcommerce codegen-interceptors` - Generate interceptor files
|
|
20
|
+
- `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
|
|
21
|
+
- **Stable file hashing** - Deterministic interceptor generation for better caching
|
|
22
|
+
|
|
23
|
+
### ⚙️ Treeshakable Configuration System
|
|
24
|
+
|
|
25
|
+
Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
|
|
26
|
+
|
|
27
|
+
- **New `codegen-config-values` command** - Generates TypeScript files with precise typing
|
|
28
|
+
- **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
|
|
29
|
+
- **Fully treeshakable** - Unused config values are eliminated from the bundle
|
|
30
|
+
- **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
|
|
31
|
+
- **Separate files for nested objects** - Optimal treeshaking for complex configurations
|
|
32
|
+
|
|
33
|
+
### 🔧 withGraphCommerce Changes
|
|
34
|
+
|
|
35
|
+
- **Removed** `InterceptorPlugin` - No longer needed with file-based interception
|
|
36
|
+
- **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
|
|
37
|
+
- **Removed** `@mui/*` alias rewrites - No longer required
|
|
38
|
+
- **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
|
|
39
|
+
- **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
|
|
40
|
+
- **Added** `optimizePackageImports` for better bundle optimization
|
|
41
|
+
- **Added** `images.qualities: [52, 75]` for Next.js image optimization
|
|
42
|
+
|
|
43
|
+
### 📦 Lingui Configuration
|
|
44
|
+
|
|
45
|
+
- **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
|
|
46
|
+
- **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
|
|
47
|
+
- **Simplified** formatter options
|
|
48
|
+
|
|
49
|
+
### ⚛️ React 19 & Next.js 16 Compatibility
|
|
50
|
+
|
|
51
|
+
- Updated `RefObject<T>` types for React 19 (now includes `null` by default)
|
|
52
|
+
- Replaced deprecated `React.VFC` with `React.FC`
|
|
53
|
+
- Fixed `useRef` calls to require explicit initial values
|
|
54
|
+
- Updated `MutableRefObject` usage in `framer-scroller`
|
|
55
|
+
|
|
56
|
+
### 📋 ESLint 9 Flat Config
|
|
57
|
+
|
|
58
|
+
- Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
|
|
59
|
+
- Updated `@typescript-eslint/*` packages to v8
|
|
60
|
+
- Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
|
|
61
|
+
|
|
62
|
+
### 🔄 Apollo Client
|
|
63
|
+
|
|
64
|
+
- Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
|
|
65
|
+
- Updated error handling types to accept `ApolloError | null | undefined`
|
|
66
|
+
|
|
67
|
+
### ⚠️ Breaking Changes
|
|
68
|
+
|
|
69
|
+
- **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
|
|
70
|
+
- **Interceptor files changed** - Original components now at `.original.tsx`
|
|
71
|
+
- **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
|
|
72
|
+
- **ESLint config format** - Must use flat config (`eslint.config.mjs`)
|
|
73
|
+
- **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
|
|
74
|
+
|
|
75
|
+
### 🗑️ Removed
|
|
76
|
+
|
|
77
|
+
- `InterceptorPlugin` webpack plugin
|
|
78
|
+
- `configToImportMeta` utility
|
|
79
|
+
- Webpack `DefinePlugin` usage for config
|
|
80
|
+
- `@mui/*` modern alias rewrites
|
|
81
|
+
- Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
|
|
82
|
+
|
|
83
|
+
- [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
|
|
84
|
+
|
|
85
|
+
### Patch Changes
|
|
86
|
+
|
|
87
|
+
- [#2537](https://github.com/graphcommerce-org/graphcommerce/pull/2537) [`6e2714c`](https://github.com/graphcommerce-org/graphcommerce/commit/6e2714ccae22b806792891928a7ec9a14c272e66) - Solve issue where cached data was stale ([@paales](https://github.com/paales))
|
|
88
|
+
|
|
89
|
+
- [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`cf9eafb`](https://github.com/graphcommerce-org/graphcommerce/commit/cf9eafb9d71991852510f632c692679810b9e76f) - Prepare the RichTex for embed and code-block ([@paales](https://github.com/paales))
|
|
90
|
+
|
|
91
|
+
- [#2487](https://github.com/graphcommerce-org/graphcommerce/pull/2487) [`2085f0b`](https://github.com/graphcommerce-org/graphcommerce/commit/2085f0b30dfadd9ab589fde962f59e87b3f30b34) - Forward `<Asset unoptimized />` component to `<Image />` ([@paales](https://github.com/paales))
|
|
92
|
+
|
|
93
|
+
## 10.0.0-canary.72
|
|
94
|
+
|
|
95
|
+
## 10.0.0-canary.71
|
|
96
|
+
|
|
97
|
+
## 10.0.0-canary.70
|
|
98
|
+
|
|
99
|
+
### Major Changes
|
|
100
|
+
|
|
101
|
+
- [#2565](https://github.com/graphcommerce-org/graphcommerce/pull/2565) [`c96dfcd`](https://github.com/graphcommerce-org/graphcommerce/commit/c96dfcdca981baca387c270ad9e2b9515cdd00cc) - Updated to Apollo Client 4 ([@paales](https://github.com/paales))
|
|
102
|
+
|
|
103
|
+
## 10.0.0-canary.69
|
|
104
|
+
|
|
3
105
|
## 10.0.0-canary.68
|
|
4
106
|
|
|
5
107
|
## 10.0.0-canary.67
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cacheFirst } from '@graphcommerce/graphql'
|
|
2
|
-
import type { ApolloClient
|
|
2
|
+
import type { ApolloClient } from '@apollo/client'
|
|
3
3
|
import type { HygraphAllPagesQuery } from '../graphql'
|
|
4
4
|
import { HygraphAllPagesDocument } from '../graphql'
|
|
5
5
|
|
|
6
6
|
type Urls = { url: string }
|
|
7
7
|
|
|
8
8
|
export async function getAllHygraphPages(
|
|
9
|
-
client: ApolloClient
|
|
9
|
+
client: ApolloClient,
|
|
10
10
|
options: { pageSize?: number } = {},
|
|
11
11
|
) {
|
|
12
12
|
const { pageSize = 100 } = options
|
|
@@ -16,10 +16,11 @@ export async function getAllHygraphPages(
|
|
|
16
16
|
variables: { first: pageSize },
|
|
17
17
|
fetchPolicy: cacheFirst(client),
|
|
18
18
|
})
|
|
19
|
-
const pages: Promise<ApolloQueryResult<HygraphAllPagesQuery>>[] = [query]
|
|
20
19
|
|
|
21
20
|
const { data } = await query
|
|
22
|
-
const totalPages = Math.ceil(data.pagesConnection.aggregate.count / pageSize)
|
|
21
|
+
const totalPages = data ? Math.ceil(data.pagesConnection.aggregate.count / pageSize) : 1
|
|
22
|
+
|
|
23
|
+
const pages = [query]
|
|
23
24
|
|
|
24
25
|
if (totalPages > 1) {
|
|
25
26
|
for (let i = 2; i <= totalPages; i++) {
|
|
@@ -34,8 +35,9 @@ export async function getAllHygraphPages(
|
|
|
34
35
|
}
|
|
35
36
|
|
|
36
37
|
const paths: Urls[] = (await Promise.all(pages))
|
|
37
|
-
.map((q) => q.data
|
|
38
|
+
.map((q) => q.data?.pages ?? [])
|
|
38
39
|
.flat(1)
|
|
40
|
+
.filter((page): page is NonNullable<typeof page> & { url: string } => !!page?.url)
|
|
39
41
|
.map((page) => ({
|
|
40
42
|
url: page.url,
|
|
41
43
|
}))
|
package/lib/getHygraphPaths.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { PageWhereInput } from '@graphcommerce/graphql-mesh'
|
|
2
|
-
import type { ApolloClient
|
|
2
|
+
import type { ApolloClient } from '@apollo/client'
|
|
3
3
|
import type { GetStaticPathsResult } from 'next'
|
|
4
|
-
import type { HygraphStaticPathsQuery } from '../graphql/HygraphStaticPaths.gql'
|
|
5
4
|
import { HygraphStaticPathsDocument } from '../graphql/HygraphStaticPaths.gql'
|
|
6
5
|
|
|
7
6
|
type Return = GetStaticPathsResult<{ url: string }>
|
|
8
7
|
|
|
9
8
|
export async function getHygraphStaticPaths(
|
|
10
|
-
client: ApolloClient
|
|
9
|
+
client: ApolloClient,
|
|
11
10
|
locale: string,
|
|
12
11
|
options: { pageSize?: number; filter?: PageWhereInput } = {},
|
|
13
12
|
) {
|
|
@@ -16,10 +15,11 @@ export async function getHygraphStaticPaths(
|
|
|
16
15
|
query: HygraphStaticPathsDocument,
|
|
17
16
|
variables: { pageSize, where: filter },
|
|
18
17
|
})
|
|
19
|
-
const pages: Promise<ApolloQueryResult<HygraphStaticPathsQuery>>[] = [query]
|
|
20
18
|
|
|
21
19
|
const { data } = await query
|
|
22
|
-
const totalPages = Math.ceil(data.pagesConnection.aggregate.count / pageSize)
|
|
20
|
+
const totalPages = data ? Math.ceil(data.pagesConnection.aggregate.count / pageSize) : 1
|
|
21
|
+
|
|
22
|
+
const pages = [query]
|
|
23
23
|
|
|
24
24
|
if (totalPages > 1) {
|
|
25
25
|
for (let i = 2; i <= totalPages; i++) {
|
|
@@ -33,9 +33,10 @@ export async function getHygraphStaticPaths(
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const paths: Return['paths'] = (await Promise.all(pages))
|
|
36
|
-
.map((q) => q.data
|
|
36
|
+
.map((q) => q.data?.pages ?? [])
|
|
37
37
|
.flat(1)
|
|
38
|
-
.
|
|
38
|
+
.filter((page): page is NonNullable<typeof page> & { url: string } => !!page?.url)
|
|
39
|
+
.map((page) => ({ params: { url: page.url }, locale }))
|
|
39
40
|
|
|
40
41
|
return paths
|
|
41
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloClient
|
|
1
|
+
import type { ApolloClient } from '@graphcommerce/graphql'
|
|
2
2
|
import type { HygraphPagesQuery } from '../graphql'
|
|
3
3
|
import { HygraphPagesDocument } from '../graphql'
|
|
4
4
|
import { getAllHygraphPages } from './getAllHygraphPages'
|
|
@@ -10,7 +10,7 @@ import { getAllHygraphPages } from './getAllHygraphPages'
|
|
|
10
10
|
* - Implements an alias sytem to merge the content of multiple pages.
|
|
11
11
|
*/
|
|
12
12
|
async function pageContent(
|
|
13
|
-
client: ApolloClient
|
|
13
|
+
client: ApolloClient,
|
|
14
14
|
url: string,
|
|
15
15
|
cached: boolean,
|
|
16
16
|
): Promise<{ data: HygraphPagesQuery }> {
|
|
@@ -34,13 +34,20 @@ async function pageContent(
|
|
|
34
34
|
// Only do the query when there the page is found in the allRoutes
|
|
35
35
|
const found = allRoutes.some((page) => page.url === url)
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if (found) {
|
|
38
|
+
const result = await client.query({
|
|
39
|
+
query: HygraphPagesDocument,
|
|
40
|
+
variables: { url },
|
|
41
|
+
fetchPolicy,
|
|
42
|
+
})
|
|
43
|
+
return { data: result.data ?? { pages: [] } }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return { data: { pages: [] } }
|
|
40
47
|
}
|
|
41
48
|
|
|
42
49
|
export async function hygraphPageContent(
|
|
43
|
-
client: ApolloClient
|
|
50
|
+
client: ApolloClient,
|
|
44
51
|
url: string,
|
|
45
52
|
additionalProperties?: Promise<object> | object,
|
|
46
53
|
cached = false,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/hygraph-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "10.0.0
|
|
5
|
+
"version": "10.0.0",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/ecommerce-ui": "^10.0.0
|
|
16
|
-
"@graphcommerce/eslint-config-pwa": "^10.0.0
|
|
17
|
-
"@graphcommerce/graphql": "^10.0.0
|
|
18
|
-
"@graphcommerce/image": "^10.0.0
|
|
19
|
-
"@graphcommerce/next-ui": "^10.0.0
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^10.0.0
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^10.0.0
|
|
15
|
+
"@graphcommerce/ecommerce-ui": "^10.0.0",
|
|
16
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0",
|
|
17
|
+
"@graphcommerce/graphql": "^10.0.0",
|
|
18
|
+
"@graphcommerce/image": "^10.0.0",
|
|
19
|
+
"@graphcommerce/next-ui": "^10.0.0",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0",
|
|
22
22
|
"@mui/material": "^7.0.0",
|
|
23
23
|
"next": "*",
|
|
24
24
|
"react": "^19.2.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql'
|
|
2
|
-
import {
|
|
2
|
+
import { SetContextLink } from '@graphcommerce/graphql'
|
|
3
3
|
import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
|
|
4
4
|
|
|
5
5
|
export const config: PluginConfig = {
|
|
@@ -18,16 +18,16 @@ export const graphqlConfig: FunctionPlugin<typeof graphqlConfigType> = (prev, co
|
|
|
18
18
|
|
|
19
19
|
const locales = conf.storefront.hygraphLocales
|
|
20
20
|
|
|
21
|
-
const hygraphLink =
|
|
22
|
-
|
|
23
|
-
if (locales)
|
|
21
|
+
const hygraphLink = new SetContextLink((prevContext) => {
|
|
22
|
+
const headers: Record<string, string> = { ...prevContext.headers }
|
|
23
|
+
if (locales) headers['gcms-locales'] = locales.join(',')
|
|
24
24
|
|
|
25
25
|
const stage = conf.previewData?.hygraphStage ?? 'DRAFT'
|
|
26
26
|
if (conf.preview) {
|
|
27
|
-
|
|
27
|
+
headers['gcms-stage'] = stage
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
return
|
|
30
|
+
return { headers }
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
return { ...results, links: [...results.links, hygraphLink] }
|