@graphcommerce/graphcms-ui 8.0.6-canary.4 → 8.1.0-canary.11

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,24 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.1.0-canary.11
4
+
5
+ ## 8.1.0-canary.10
6
+
7
+ ## 8.1.0-canary.9
8
+
9
+ ### Patch Changes
10
+
11
+ - [#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
12
+ ([@bramvanderholst](https://github.com/bramvanderholst))
13
+
14
+ ## 8.1.0-canary.8
15
+
16
+ ## 8.1.0-canary.7
17
+
18
+ ## 8.1.0-canary.6
19
+
20
+ ## 8.1.0-canary.5
21
+
3
22
  ## 8.0.6-canary.4
4
23
 
5
24
  ## 8.0.6-canary.3
@@ -0,0 +1,11 @@
1
+ query HygraphStaticPaths($pageSize: Int!, $skip: Int, $where: PageWhereInput) {
2
+ pages(first: $pageSize, skip: $skip, where: $where) {
3
+ url
4
+ }
5
+
6
+ pagesConnection {
7
+ aggregate {
8
+ count
9
+ }
10
+ }
11
+ }
@@ -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
+ }
package/lib/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './hygraphPageContent'
2
+ export * from './getHygraphPaths'
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.0.6-canary.4",
5
+ "version": "8.1.0-canary.11",
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.0.6-canary.4",
16
- "@graphcommerce/graphql": "^8.0.6-canary.4",
17
- "@graphcommerce/image": "^8.0.6-canary.4",
18
- "@graphcommerce/next-ui": "^8.0.6-canary.4",
19
- "@graphcommerce/prettier-config-pwa": "^8.0.6-canary.4",
20
- "@graphcommerce/typescript-config-pwa": "^8.0.6-canary.4",
15
+ "@graphcommerce/eslint-config-pwa": "^8.1.0-canary.11",
16
+ "@graphcommerce/graphql": "^8.1.0-canary.11",
17
+ "@graphcommerce/image": "^8.1.0-canary.11",
18
+ "@graphcommerce/next-ui": "^8.1.0-canary.11",
19
+ "@graphcommerce/prettier-config-pwa": "^8.1.0-canary.11",
20
+ "@graphcommerce/typescript-config-pwa": "^8.1.0-canary.11",
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 { MethodPlugin } from '@graphcommerce/next-config'
2
+ import type { FunctionPlugin } from '@graphcommerce/next-config'
3
3
 
4
4
  export const func = 'graphqlConfig'
5
- export const exported = '@graphcommerce/graphql/config'
5
+ export const exported = '@graphcommerce/graphql'
6
6
 
7
- const hygraphGraphqlConfig: MethodPlugin<typeof graphqlConfig> = (prev, config) => {
7
+ const hygraphGraphqlConfig: FunctionPlugin<typeof graphqlConfig> = (prev, config) => {
8
8
  const results = prev(config)
9
9
 
10
10
  const locales = config.storefront.hygraphLocales