@graphcommerce/graphcms-ui 3.1.9 → 3.2.0-canary.4
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 -2
- package/index.ts +1 -0
- package/links/createHygraphLink.ts +22 -0
- package/package.json +4 -4
- package/plugins/HygraphGraphqlProvider.tsx +13 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## 3.
|
|
3
|
+
## 3.2.0-canary.4
|
|
4
4
|
|
|
5
|
-
## 3.
|
|
5
|
+
## 3.2.0-canary.3
|
|
6
|
+
|
|
7
|
+
### Minor Changes
|
|
8
|
+
|
|
9
|
+
- [#1733](https://github.com/graphcommerce-org/graphcommerce/pull/1733) [`761bd2832`](https://github.com/graphcommerce-org/graphcommerce/commit/761bd2832f115afc8b95bedbf479266309dd5acc) - ApolloLinks, typePolicies and migration scripts are now handled with plugins on the new library component `<GraphQLProvider/>`. Hygraph's, Magento Cart, Customer, Store, Wishlist and Magento GraphQL are all migrated to be using plugins.
|
|
10
|
+
|
|
11
|
+
If you are using custom `links` / `policies` / `migrations` you can pass them as props to the `<GraphQLProvider/>` or create your own local plugin. ([@paales](https://github.com/paales))
|
|
12
|
+
|
|
13
|
+
## 3.1.8-canary.2
|
|
14
|
+
|
|
15
|
+
## 3.1.8-canary.1
|
|
16
|
+
|
|
17
|
+
## 3.1.8-canary.0
|
|
6
18
|
|
|
7
19
|
## 3.1.7
|
|
8
20
|
|
package/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ClientContext, setContext } from '@graphcommerce/graphql'
|
|
2
|
+
import { defaultLocale } from '@graphcommerce/magento-store'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Add a gcms-locales header to make sure queries return in a certain language with a fallback to
|
|
6
|
+
* defaultLocale().
|
|
7
|
+
*
|
|
8
|
+
* This will create a fallback list like: `nl_nl,nl,en_us,en`
|
|
9
|
+
*/
|
|
10
|
+
export const createHygraphLink = (locale?: string) =>
|
|
11
|
+
setContext((_, context: ClientContext) => {
|
|
12
|
+
if (!context.headers) context.headers = {}
|
|
13
|
+
|
|
14
|
+
const gcmsLocales = [
|
|
15
|
+
locale?.replace('-', '_'),
|
|
16
|
+
locale?.split('-')[0],
|
|
17
|
+
defaultLocale().replace('-', '_'),
|
|
18
|
+
defaultLocale().split('-')[0],
|
|
19
|
+
]
|
|
20
|
+
context.headers['gcms-locales'] = gcmsLocales.filter(Boolean).join(',')
|
|
21
|
+
return context
|
|
22
|
+
})
|
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": "3.
|
|
5
|
+
"version": "3.2.0-canary.4",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"type-fest": "^2.12.2"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@graphcommerce/graphql": "4.
|
|
23
|
-
"@graphcommerce/image": "4.
|
|
24
|
-
"@graphcommerce/next-ui": "4.
|
|
22
|
+
"@graphcommerce/graphql": "4.31.0-canary.4",
|
|
23
|
+
"@graphcommerce/image": "4.31.0-canary.4",
|
|
24
|
+
"@graphcommerce/next-ui": "4.31.0-canary.4"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@mui/material": "5.5.3",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GraphQLProviderProps } from '@graphcommerce/graphql'
|
|
2
|
+
import type { PluginProps } from '@graphcommerce/next-config'
|
|
3
|
+
import { createHygraphLink } from '../links/createHygraphLink'
|
|
4
|
+
|
|
5
|
+
export const component = 'GraphQLProvider'
|
|
6
|
+
export const exported = '@graphcommerce/graphql'
|
|
7
|
+
|
|
8
|
+
function HygraphGraphqlProvider(props: PluginProps<GraphQLProviderProps>) {
|
|
9
|
+
const { Prev, links = [], ...prev } = props
|
|
10
|
+
return <Prev {...prev} links={[...links, createHygraphLink(prev.router.locale)]} />
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Plugin = HygraphGraphqlProvider
|