@graphcommerce/graphcms-ui 8.1.0-canary.2 → 8.1.0-canary.22
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 +107 -1
- package/graphql/HygraphAllPages.graphql +8 -2
- package/graphql/HygraphStaticPaths.graphql +11 -0
- package/lib/getAllHygraphPages.ts +41 -0
- package/lib/getHygraphPaths.ts +43 -0
- package/lib/hygraphPageContent.ts +4 -4
- package/lib/index.ts +1 -0
- package/package.json +7 -7
- package/plugins/hygraphGraphqlConfig.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,112 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 8.1.0-canary.
|
|
3
|
+
## 8.1.0-canary.22
|
|
4
|
+
|
|
5
|
+
## 8.1.0-canary.21
|
|
6
|
+
|
|
7
|
+
## 8.1.0-canary.20
|
|
8
|
+
|
|
9
|
+
## 8.1.0-canary.19
|
|
10
|
+
|
|
11
|
+
## 8.1.0-canary.18
|
|
12
|
+
|
|
13
|
+
## 8.1.0-canary.17
|
|
14
|
+
|
|
15
|
+
## 8.1.0-canary.16
|
|
16
|
+
|
|
17
|
+
## 8.1.0-canary.15
|
|
18
|
+
|
|
19
|
+
## 8.1.0-canary.14
|
|
20
|
+
|
|
21
|
+
## 8.1.0-canary.13
|
|
22
|
+
|
|
23
|
+
## 8.1.0-canary.12
|
|
24
|
+
|
|
25
|
+
## 8.1.0-canary.11
|
|
26
|
+
|
|
27
|
+
## 8.1.0-canary.10
|
|
28
|
+
|
|
29
|
+
## 8.1.0-canary.9
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- [#2223](https://github.com/graphcommerce-org/graphcommerce/pull/2223) [`0ccec63`](https://github.com/graphcommerce-org/graphcommerce/commit/0ccec630825d5fad398366beae90b3c90b2f84b8) - Added helper method to get Hygraph paths
|
|
34
|
+
([@bramvanderholst](https://github.com/bramvanderholst))
|
|
35
|
+
|
|
36
|
+
## 8.1.0-canary.8
|
|
37
|
+
|
|
38
|
+
## 8.1.0-canary.7
|
|
39
|
+
|
|
40
|
+
## 8.1.0-canary.6
|
|
41
|
+
|
|
42
|
+
## 8.1.0-canary.5
|
|
43
|
+
|
|
44
|
+
## 8.0.6-canary.4
|
|
45
|
+
|
|
46
|
+
## 8.0.6-canary.3
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- [#2219](https://github.com/graphcommerce-org/graphcommerce/pull/2219) [`2ed2055`](https://github.com/graphcommerce-org/graphcommerce/commit/2ed20550324c104265d72f22339fbedb26fb433b) - Allow blog pages to be nested
|
|
51
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
52
|
+
|
|
53
|
+
## 8.0.6-canary.2
|
|
54
|
+
|
|
55
|
+
## 8.0.6-canary.1
|
|
56
|
+
|
|
57
|
+
## 8.0.6-canary.0
|
|
58
|
+
|
|
59
|
+
## 8.0.5
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination.
|
|
64
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
65
|
+
|
|
66
|
+
## 8.0.5-canary.10
|
|
67
|
+
|
|
68
|
+
## 8.0.5-canary.9
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- [#2238](https://github.com/graphcommerce-org/graphcommerce/pull/2238) [`db86432`](https://github.com/graphcommerce-org/graphcommerce/commit/db864324277fd5fb680c66eaa87d211cd7be4905) - Changed query limit to 100 from a 1000 on HygraphAllPages and AllDynamicRows query and added pagination.
|
|
73
|
+
([@Jessevdpoel](https://github.com/Jessevdpoel))
|
|
74
|
+
|
|
75
|
+
## 8.0.5-canary.8
|
|
76
|
+
|
|
77
|
+
## 8.0.5-canary.7
|
|
78
|
+
|
|
79
|
+
## 8.0.5-canary.6
|
|
80
|
+
|
|
81
|
+
## 8.0.5-canary.5
|
|
82
|
+
|
|
83
|
+
## 8.0.5-canary.4
|
|
84
|
+
|
|
85
|
+
## 8.0.5-canary.3
|
|
86
|
+
|
|
87
|
+
## 8.0.5-canary.2
|
|
88
|
+
|
|
89
|
+
## 8.0.5-canary.1
|
|
90
|
+
|
|
91
|
+
## 8.0.5-canary.0
|
|
92
|
+
|
|
93
|
+
## 8.0.4
|
|
94
|
+
|
|
95
|
+
## 8.0.4-canary.1
|
|
96
|
+
|
|
97
|
+
## 8.0.4-canary.0
|
|
98
|
+
|
|
99
|
+
## 8.0.3
|
|
100
|
+
|
|
101
|
+
## 8.0.3-canary.6
|
|
102
|
+
|
|
103
|
+
## 8.0.3-canary.5
|
|
104
|
+
|
|
105
|
+
## 8.0.3-canary.4
|
|
106
|
+
|
|
107
|
+
## 8.0.3-canary.3
|
|
108
|
+
|
|
109
|
+
## 8.0.3-canary.2
|
|
4
110
|
|
|
5
111
|
## 8.0.3-canary.1
|
|
6
112
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ApolloClient, NormalizedCacheObject, ApolloQueryResult } from '@apollo/client'
|
|
2
|
+
import { HygraphAllPagesDocument, HygraphAllPagesQuery } from '../graphql'
|
|
3
|
+
|
|
4
|
+
type Urls = { url: string }
|
|
5
|
+
|
|
6
|
+
export async function getAllHygraphPages(
|
|
7
|
+
client: ApolloClient<NormalizedCacheObject>,
|
|
8
|
+
options: { pageSize?: number } = {},
|
|
9
|
+
) {
|
|
10
|
+
const { pageSize = 100 } = options
|
|
11
|
+
const query = client.query({
|
|
12
|
+
query: HygraphAllPagesDocument,
|
|
13
|
+
variables: { first: pageSize },
|
|
14
|
+
fetchPolicy: process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined,
|
|
15
|
+
})
|
|
16
|
+
const pages: Promise<ApolloQueryResult<HygraphAllPagesQuery>>[] = [query]
|
|
17
|
+
|
|
18
|
+
const { data } = await query
|
|
19
|
+
const totalPages = Math.ceil(data.pagesConnection.aggregate.count / pageSize) ?? 1
|
|
20
|
+
|
|
21
|
+
if (totalPages > 1) {
|
|
22
|
+
for (let i = 2; i <= totalPages; i++) {
|
|
23
|
+
pages.push(
|
|
24
|
+
client.query({
|
|
25
|
+
query: HygraphAllPagesDocument,
|
|
26
|
+
variables: { first: pageSize, skip: pageSize * (i - 1) },
|
|
27
|
+
fetchPolicy: process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined,
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const paths: Urls[] = (await Promise.all(pages))
|
|
34
|
+
.map((q) => q.data.pages)
|
|
35
|
+
.flat(1)
|
|
36
|
+
.map((page) => ({
|
|
37
|
+
url: page.url,
|
|
38
|
+
}))
|
|
39
|
+
|
|
40
|
+
return paths
|
|
41
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject, ApolloQueryResult } from '@apollo/client'
|
|
2
|
+
import type { PageWhereInput } from '@graphcommerce/graphql-mesh'
|
|
3
|
+
import { GetStaticPathsResult } from 'next'
|
|
4
|
+
import {
|
|
5
|
+
HygraphStaticPathsDocument,
|
|
6
|
+
HygraphStaticPathsQuery,
|
|
7
|
+
} from '../graphql/HygraphStaticPaths.gql'
|
|
8
|
+
|
|
9
|
+
type Return = GetStaticPathsResult<{ url: string }>
|
|
10
|
+
|
|
11
|
+
export async function getHygraphStaticPaths(
|
|
12
|
+
client: ApolloClient<NormalizedCacheObject>,
|
|
13
|
+
locale: string,
|
|
14
|
+
options: { pageSize?: number; filter?: PageWhereInput } = {},
|
|
15
|
+
) {
|
|
16
|
+
const { pageSize = 100, filter = {} } = options
|
|
17
|
+
const query = client.query({
|
|
18
|
+
query: HygraphStaticPathsDocument,
|
|
19
|
+
variables: { pageSize, where: filter },
|
|
20
|
+
})
|
|
21
|
+
const pages: Promise<ApolloQueryResult<HygraphStaticPathsQuery>>[] = [query]
|
|
22
|
+
|
|
23
|
+
const { data } = await query
|
|
24
|
+
const totalPages = Math.ceil(data.pagesConnection.aggregate.count / pageSize) ?? 1
|
|
25
|
+
|
|
26
|
+
if (totalPages > 1) {
|
|
27
|
+
for (let i = 2; i <= totalPages; i++) {
|
|
28
|
+
pages.push(
|
|
29
|
+
client.query({
|
|
30
|
+
query: HygraphStaticPathsDocument,
|
|
31
|
+
variables: { pageSize, skip: pageSize * (i - 1), where: filter },
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const paths: Return['paths'] = (await Promise.all(pages))
|
|
38
|
+
.map((q) => q.data.pages)
|
|
39
|
+
.flat(1)
|
|
40
|
+
.map((page) => ({ params: page, locale }))
|
|
41
|
+
|
|
42
|
+
return paths
|
|
43
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
2
|
-
import {
|
|
2
|
+
import { HygraphPagesQuery, HygraphPagesDocument } from '../graphql'
|
|
3
|
+
import { getAllHygraphPages } from './getAllHygraphPages'
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Fetch the page content for the given urls.
|
|
@@ -28,10 +29,9 @@ async function pageContent(
|
|
|
28
29
|
const alwaysCache = process.env.NODE_ENV !== 'development' ? 'cache-first' : undefined
|
|
29
30
|
const fetchPolicy = cached ? alwaysCache : undefined
|
|
30
31
|
|
|
31
|
-
const allRoutes = await client
|
|
32
|
-
|
|
32
|
+
const allRoutes = await getAllHygraphPages(client)
|
|
33
33
|
// Only do the query when there the page is found in the allRoutes
|
|
34
|
-
const found = allRoutes.
|
|
34
|
+
const found = allRoutes.some((page) => page.url === url)
|
|
35
35
|
|
|
36
36
|
return found
|
|
37
37
|
? client.query({ query: HygraphPagesDocument, variables: { url }, fetchPolicy })
|
package/lib/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphcms-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "8.1.0-canary.
|
|
5
|
+
"version": "8.1.0-canary.22",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.
|
|
16
|
-
"@graphcommerce/graphql": "^8.1.0-canary.
|
|
17
|
-
"@graphcommerce/image": "^8.1.0-canary.
|
|
18
|
-
"@graphcommerce/next-ui": "^8.1.0-canary.
|
|
19
|
-
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^8.1.0-canary.22",
|
|
16
|
+
"@graphcommerce/graphql": "^8.1.0-canary.22",
|
|
17
|
+
"@graphcommerce/image": "^8.1.0-canary.22",
|
|
18
|
+
"@graphcommerce/next-ui": "^8.1.0-canary.22",
|
|
19
|
+
"@graphcommerce/prettier-config-pwa": "^8.1.0-canary.22",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^8.1.0-canary.22",
|
|
21
21
|
"@mui/material": "^5.10.16",
|
|
22
22
|
"next": "*",
|
|
23
23
|
"react": "^18.2.0",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { graphqlConfig, setContext } from '@graphcommerce/graphql'
|
|
2
|
-
import type {
|
|
2
|
+
import type { FunctionPlugin } from '@graphcommerce/next-config'
|
|
3
3
|
|
|
4
4
|
export const func = 'graphqlConfig'
|
|
5
|
-
export const exported = '@graphcommerce/graphql
|
|
5
|
+
export const exported = '@graphcommerce/graphql'
|
|
6
6
|
|
|
7
|
-
const hygraphGraphqlConfig:
|
|
7
|
+
const hygraphGraphqlConfig: FunctionPlugin<typeof graphqlConfig> = (prev, config) => {
|
|
8
8
|
const results = prev(config)
|
|
9
9
|
|
|
10
10
|
const locales = config.storefront.hygraphLocales
|