@graphcommerce/docs 6.0.0-canary.26 → 6.0.0-canary.28

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
  # Change Log
2
2
 
3
+ ## 6.0.0-canary.28
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1823](https://github.com/graphcommerce-org/graphcommerce/pull/1823) [`605d74434`](https://github.com/graphcommerce-org/graphcommerce/commit/605d74434b78baa83f3574b6a4249eae0431d570) - Fix/upgrade instructions ([@paales](https://github.com/paales))
8
+
9
+ ## 6.0.0-canary.27
10
+
3
11
  ## 6.0.0-canary.26
4
12
 
5
13
  ## 6.0.0-canary.25
@@ -1,9 +1,79 @@
1
- <!-- auto generated -->
2
- ## GraphCommerceConfig
1
+ <!-- Automatically generated from Config.graphqls -->
2
+ # GraphCommerce configuration system
3
3
 
4
- Global GraphCommerce configuration can be configured in your `graphcommerce.config.js` file in the root of your project.
4
+ Global GraphCommerce configuration can be configured in your `graphcommerce.config.js` file
5
+ in the root of your project and are automatically validated on startup.
5
6
 
6
- ### `canonicalBaseUrl: String!`
7
+ ## Configuring with the configuration file.
8
+
9
+ The configuration file is a javascript file that exports a `GraphCommerceConfig` object. See graphcommerce.config.js.example for an example.
10
+
11
+ ## Using configuration
12
+
13
+ Configuration can be accessed in your project with the `import.meta.graphCommerce` object.
14
+
15
+ ```tsx
16
+ import { i18nAll, i18nConfig, i18nConfigDefault, useI18nConfig } from '@graphcommerce/next-ui'
17
+
18
+ // Accessing a global value
19
+ const globalConf = import.meta.graphCommerce.cartDisplayPricesInclTax
20
+
21
+ function MyComponent() {
22
+ // Configuration configured per i18n locale.
23
+ const scopedConfig = useI18nConfig().cartDisplayPricesInclTax
24
+
25
+ // Creating a fallback system
26
+ const scopedConfigWithFallback = scopedConfig ?? globalConf
27
+
28
+ // Or as single line
29
+ const scopedConfigWithFallback2 =
30
+ useI18nConfig().cartDisplayPricesInclTax ?? import.meta.graphCommerce.cartDisplayPricesInclTax
31
+
32
+ return <div>{googleRecaptchaKey}</div>
33
+ }
34
+ ```
35
+
36
+ ## Environment variables to override configuration
37
+
38
+ Configuration values can be overwriten by environment variables, with the following rules:
39
+ - Convert from camelCase to `SCREAMING_SNAKE_CASE`
40
+ - Prefix with `GC_`
41
+ - Arrays can be indexed with _0, _1, _2, etc.
42
+ - Objects can be accessed with _<key>.
43
+
44
+ Examples:
45
+ - `limitSsg` -> `GC_LIMIT_SSG="1"`
46
+ - `i18n[0].locale` -> `GC_I18N_0_LOCALE="en"`
47
+ - `debug.pluginStatus` -> `GC_DEBUG_PLUGIN_STATUS="1"`
48
+
49
+
50
+ ## Extending the configuration in your project
51
+
52
+ Create a graphql/Config.graphqls file in your project and extend the GraphCommerceConfig, GraphCommerceI18nConfig inputs to add configuration.
53
+
54
+ ```graphql
55
+ extend input GraphCommerceConfig {
56
+ myOptionalBoolean: Boolean
57
+ myRequiredBoolean: Boolean!
58
+ myOptionalString: String
59
+ myRequiredString: String!
60
+ myOptionalInt: Int
61
+ myRequiredInt: Int!
62
+ myOptionalFloat: Float
63
+ myRequiredFloat: Float!
64
+ }
65
+ extend input GraphCommerceI18nConfig {
66
+ myField: Boolean
67
+ }
68
+ ```
69
+
70
+ ## All configuration values
71
+
72
+ Below is a list of all possible configurations that can be set by GraphCommerce.
73
+
74
+ ### GraphCommerceConfig
75
+
76
+ #### `canonicalBaseUrl: String!`
7
77
 
8
78
  The canonical base URL is used for SEO purposes.
9
79
 
@@ -12,47 +82,30 @@ Examples:
12
82
  - https://example.com/en
13
83
  - https://example.com/en-US
14
84
 
15
- ### `hygraphEndpoint: String!`
85
+ #### `hygraphEndpoint: String!`
16
86
 
17
87
  The HyGraph endpoint.
18
88
 
19
89
  Project settings -> API Access -> High Performance Read-only Content API
20
90
 
21
- ### `i18n: [GraphCommerceI18nConfig!]!`
91
+ #### `i18n: [[GraphCommerceI18nConfig](#GraphCommerceI18nConfig)!]!`
22
92
 
23
93
  All i18n configuration for the project
24
94
 
25
- ### `magentoEndpoint: String!`
95
+ #### `magentoEndpoint: String!`
26
96
 
27
97
  GraphQL Magento endpoint.
28
98
 
29
99
  Examples:
30
100
  - https://magento2.test/graphql
31
101
 
32
- ### `productFiltersPro: Boolean!`
33
-
34
- Product filters with better UI for mobile and desktop.
35
-
36
- @experimental This is an experimental feature and may change in the future.
37
-
38
- ### `robotsAllow: Boolean!`
39
-
40
- Allow the site to be indexed by search engines.
41
- If false, the robots.txt file will be set to disallow all.
42
-
43
- ### `singleProductRoute: Boolean!`
44
-
45
- On older versions of GraphCommerce products would use a product type specific route.
46
-
47
- This should only be set to false if you use the /product/[url] or /product/configurable/[url] routes.
48
-
49
- ### `cartDisplayPricesInclTax: Boolean`
102
+ #### `cartDisplayPricesInclTax: Boolean`
50
103
 
51
104
  Due to a limitation of the GraphQL API it is not possible to determine if a cart should be displayed including or excluding tax.
52
105
 
53
106
  When Magento's StoreConfig adds this value, this can be replaced.
54
107
 
55
- ### `customerRequireEmailConfirmation: Boolean`
108
+ #### `customerRequireEmailConfirmation: Boolean`
56
109
 
57
110
  Due to a limitation in the GraphQL API of Magento 2, we need to know if the
58
111
  customer requires email confirmation.
@@ -60,11 +113,11 @@ customer requires email confirmation.
60
113
  This value should match Magento 2's configuration value for
61
114
  `customer/create_account/confirm` and should be removed once we can query
62
115
 
63
- ### `debug: GraphCommerceDebugConfig`
116
+ #### `debug: [GraphCommerceDebugConfig](#GraphCommerceDebugConfig)`
64
117
 
65
118
  Debug configuration for GraphCommerce
66
119
 
67
- ### `demoMode: Boolean`
120
+ #### `demoMode: Boolean`
68
121
 
69
122
  Enables some demo specific code that is probably not useful for a project:
70
123
 
@@ -72,7 +125,7 @@ Enables some demo specific code that is probably not useful for a project:
72
125
  - Adds "dominant_color" attribute swatches to the product list items.
73
126
  - Creates a big list items in the product list.
74
127
 
75
- ### `googleAnalyticsId: String`
128
+ #### `googleAnalyticsId: String`
76
129
 
77
130
  See https://support.google.com/analytics/answer/9539598?hl=en
78
131
 
@@ -80,50 +133,67 @@ Provide a value to enable Google Analytics for your store.
80
133
 
81
134
  To enable only for a specific locale, override the value in the i18n config.
82
135
 
83
- ### `googleRecaptchaKey: String`
136
+ #### `googleRecaptchaKey: String`
84
137
 
85
138
  Google reCAPTCHA key, get from https://developers.google.com/recaptcha/docs/v3
86
139
 
87
140
  This value is required even if you are configuring different values for each locale.
88
141
 
89
- ### `googleTagmanagerId: String`
142
+ #### `googleTagmanagerId: String`
90
143
 
91
144
  The Google Tagmanager ID to be used on the site.
92
145
 
93
146
  This value is required even if you are configuring different values for each locale.
94
147
 
95
- ### `limitSsg: Boolean`
148
+ #### `legacyProductRoute: Boolean`
149
+
150
+ On older versions of GraphCommerce products would use a product type specific route.
151
+
152
+ This should only be set to true if you use the /product/[url] AND /product/configurable/[url] routes.
153
+
154
+ #### `limitSsg: Boolean`
96
155
 
97
156
  Limit the static generation of SSG when building
98
157
 
99
- ### `previewSecret: String`
158
+ #### `previewSecret: String`
100
159
 
101
160
  To enable next.js' preview mode, configure the secret you'd like to use.
102
161
 
103
- ### `wishlistHideForGuests: Boolean`
162
+ #### `productFiltersPro: Boolean`
163
+
164
+ Product filters with better UI for mobile and desktop.
165
+
166
+ @experimental This is an experimental feature and may change in the future.
167
+
168
+ #### `robotsAllow: Boolean`
169
+
170
+ Allow the site to be indexed by search engines.
171
+ If false, the robots.txt file will be set to disallow all.
172
+
173
+ #### `wishlistHideForGuests: Boolean`
104
174
 
105
175
  Hide the wishlist functionality for guests.
106
176
 
107
- ### `wishlistIgnoreProductWishlistStatus: Boolean`
177
+ #### `wishlistIgnoreProductWishlistStatus: Boolean`
108
178
 
109
179
  Ignores wether a product is already in the wishlist, makes the toggle an add only.
110
180
 
111
- ## GraphCommerceDebugConfig
181
+ ### GraphCommerceDebugConfig
112
182
 
113
183
  Debug configuration for GraphCommerce
114
184
 
115
- ### `pluginStatus: Boolean`
185
+ #### `pluginStatus: Boolean`
116
186
 
117
187
  Reports which plugins are enabled or disabled.
118
188
 
119
- ### `webpackCircularDependencyPlugin: Boolean`
189
+ #### `webpackCircularDependencyPlugin: Boolean`
120
190
 
121
191
  Cyclic dependencies can cause memory issues and other strange bugs.
122
192
  This plugin will warn you when it detects a cyclic dependency.
123
193
 
124
194
  When running into memory issues, it can be useful to enable this plugin.
125
195
 
126
- ### `webpackDuplicatesPlugin: Boolean`
196
+ #### `webpackDuplicatesPlugin: Boolean`
127
197
 
128
198
  When updating packages it can happen that the same package is included with different versions in the same project.
129
199
 
@@ -131,15 +201,15 @@ Issues that this can cause are:
131
201
  - The same package is included multiple times in the bundle, increasing the bundle size.
132
202
  - The Typescript types of the package are not compatible with each other, causing Typescript errors.
133
203
 
134
- ## GraphCommerceI18nConfig
204
+ ### GraphCommerceI18nConfig
135
205
 
136
206
  All i18n configuration for the project
137
207
 
138
- ### `locale: String!`
208
+ #### `locale: String!`
139
209
 
140
210
  Must be a locale string https://www.unicode.org/reports/tr35/tr35-59/tr35.html#Identifiers
141
211
 
142
- ### `magentoStoreCode: String!`
212
+ #### `magentoStoreCode: String!`
143
213
 
144
214
  Magento store code.
145
215
 
@@ -150,7 +220,7 @@ Examples:
150
220
  - en-us
151
221
  - b2b-us
152
222
 
153
- ### `canonicalBaseUrl: String`
223
+ #### `canonicalBaseUrl: String`
154
224
 
155
225
  The canonical base URL is used for SEO purposes.
156
226
 
@@ -159,38 +229,38 @@ Examples:
159
229
  - https://example.com/en
160
230
  - https://example.com/en-US
161
231
 
162
- ### `cartDisplayPricesInclTax: Boolean`
232
+ #### `cartDisplayPricesInclTax: Boolean`
163
233
 
164
234
  Due to a limitation of the GraphQL API it is not possible to determine if a cart should be displayed including or excluding tax.
165
235
 
166
- ### `defaultLocale: Boolean`
236
+ #### `defaultLocale: Boolean`
167
237
 
168
238
  There can only be one entry with defaultLocale set to true.
169
239
  - If there are more, the first one is used.
170
240
  - If there is none, the first entry is used.
171
241
 
172
- ### `domain: String`
242
+ #### `domain: String`
173
243
 
174
244
  Domain configuration, must be a domain https://tools.ietf.org/html/rfc3986
175
245
 
176
- ### `googleAnalyticsId: String`
246
+ #### `googleAnalyticsId: String`
177
247
 
178
248
  Configure different Google Analytics IDs for different locales.
179
249
 
180
250
  To disable for a specific locale, set the value to null.
181
251
 
182
- ### `googleRecaptchaKey: String`
252
+ #### `googleRecaptchaKey: String`
183
253
 
184
254
  Locale specific google reCAPTCHA key.
185
255
 
186
- ### `googleTagmanagerId: String`
256
+ #### `googleTagmanagerId: String`
187
257
 
188
258
  The Google Tagmanager ID to be used per locale.
189
259
 
190
- ### `hygraphLocales: [String!]`
260
+ #### `hygraphLocales: [String!]`
191
261
 
192
262
  Add a gcms-locales header to make sure queries return in a certain language, can be an array to define fallbacks.
193
263
 
194
- ### `linguiLocale: String`
264
+ #### `linguiLocale: String`
195
265
 
196
266
  Specify a custom locale for to load translations.
@@ -36,8 +36,8 @@ If you want to use props of next/link and satisfy typescript you need to provide
36
36
  `component={NextLink}`.
37
37
 
38
38
  ```tsx
39
- import { Link } from '@mui/material'
40
39
  import { NextLink } from '@graphcommerce/next-ui'
40
+ import { Link } from '@mui/material'
41
41
 
42
42
  function MyComponent() {
43
43
  return (
@@ -51,72 +51,14 @@ function MyComponent() {
51
51
  ### Using next/link with a custom component
52
52
 
53
53
  ```tsx
54
- import { Chip } from '@mui/material'
55
54
  import { NextLink } from '@graphcommerce/next-ui'
55
+ import { Chip } from '@mui/material'
56
56
 
57
57
  function MyComponent() {
58
58
  return <Chip component={NextLink} href={`/${url}`} label={'my label'} />
59
59
  }
60
60
  ```
61
61
 
62
- ## Upgrading from Next.js 12
63
-
64
- Before Next.js 13, the next/link component needed to wrap a Material-UI Link
65
- component;
66
-
67
- ```tsx
68
- import PageLink from 'next/link'
69
- import { Link } from '@mui/material'
70
-
71
- function MyComponent() {
72
- return (
73
- <PageLink href='/about' passHref>
74
- <Link>About</Link>
75
- </PageLink>
76
- )
77
- }
78
- ```
79
-
80
- To upgrade this component to Next.js 13, you can remove the PageLink component.
81
-
82
- ```tsx
83
- import { Link } from '@mui/material'
84
-
85
- function MyComponent() {
86
- return <Link href='/about'>About</Link>
87
- }
88
- ```
89
-
90
- ### Upgrading a Link that uses next/link props
91
-
92
- ```tsx
93
- import PageLink from 'next/link'
94
- import { Link } from '@mui/material'
95
-
96
- function MyComponent() {
97
- return (
98
- <PageLink href='/about' passHref prefetch={false}>
99
- <Link>Link without prefetch</Link>
100
- </PageLink>
101
- )
102
- }
103
- ```
104
-
105
- ```tsx
106
- import { Link } from '@mui/material'
107
- import { NextLink } from '@graphcommerce/next-ui'
108
-
109
- function MyComponent() {
110
- return (
111
- <>
112
- <Link href='/about' component={NextLink} prefetch={false}>
113
- Link without prefetch
114
- </Link>
115
- </>
116
- )
117
- }
118
- ```
119
-
120
62
  ## Further reading
121
63
 
122
64
  -
@@ -0,0 +1,28 @@
1
+ # Patch package
2
+
3
+ GraphCommerce relies on [patch-package ↗](https://github.com/ds300/patch-package) to make modifications to GraphCommerce where there are no ways to modify through props or plugins.
4
+
5
+ `yarn create-patch @graphcommerce/magento-store`
6
+
7
+ ## Benefits of patching over copying a file to local
8
+
9
+ - Get told in big red letters when the original file is changed and you need to check that your fix is still valid.
10
+ - Patches can be reviewed as part of your normal review process, local changes will slip though the cracks.
11
+
12
+ ## When to make a local copy of a file
13
+
14
+ - The change is too consequential to be modified in place.
15
+
16
+ ## Isn't this dangerous?
17
+
18
+ Nope. The technique is quite robust. Here are some things to keep in mind though:
19
+
20
+ - It's easy to forget to run yarn or npm when switching between branches that do and don't have patch files.
21
+ - Long lived patches can be costly to maintain if they affect an area of code that is updated regularly and you want to update the package regularly too.
22
+ - Big semantic changes can be hard to review. Keep them small and obvious or add plenty of comments.
23
+ - Changes can also impact the behaviour of other untouched packages. It's normally obvious when this will happen, and often desired, but be careful nonetheless.
24
+
25
+ ## How to make a patch
26
+
27
+ 1. Make your changes to the file in node_modules.
28
+ 2. Run `yarn create-patch @graphcommerce/magento-store` to create a patch file.
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@graphcommerce/docs",
3
3
  "homepage": "https://www.graphcommerce.org/docs",
4
4
  "repository": "github:graphcommerce-org/graphcommerce/docs",
5
- "version": "6.0.0-canary.26",
5
+ "version": "6.0.0-canary.28",
6
6
  "sideEffects": true,
7
7
  "devDependencies": {
8
- "@graphcommerce/prettier-config-pwa": "6.0.0-canary.26"
8
+ "@graphcommerce/prettier-config-pwa": "6.0.0-canary.28"
9
9
  },
10
10
  "prettier": "@graphcommerce/prettier-config-pwa"
11
11
  }
@@ -0,0 +1,135 @@
1
+ # Upgrading from GraphCommerce 5 to 6
2
+
3
+ Upgrading from GraphCommerce 5 to 6 is a major upgrade. Please follow the
4
+ regular [upgrade steps first](./readme.md).
5
+
6
+ ## Replace next/link with GraphCommerce's new Link behavior
7
+
8
+ Before GraphCommerce 6 (before Next.js 13), the next/link component needed to
9
+ wrap a Material-UI Link component; With GraphCommerce 6 we've integrated Next.js
10
+ 13's new Link behavior, see [links documentation](../framework/links.md).
11
+
12
+ ```tsx
13
+ import PageLink from 'next/link'
14
+ import { Link } from '@mui/material'
15
+
16
+ function MyComponent() {
17
+ return (
18
+ <PageLink href='/about' passHref>
19
+ <Link>About</Link>
20
+ </PageLink>
21
+ )
22
+ }
23
+ ```
24
+
25
+ To upgrade this component to Next.js 13, you can remove the PageLink component.
26
+
27
+ ```tsx
28
+ import { Link } from '@mui/material'
29
+
30
+ function MyComponent() {
31
+ return <Link href='/about'>About</Link>
32
+ }
33
+ ```
34
+
35
+ ### Upgrading a Link that uses next/link props
36
+
37
+ ```tsx
38
+ import PageLink from 'next/link'
39
+ import { Link } from '@mui/material'
40
+
41
+ function MyComponent() {
42
+ return (
43
+ <PageLink href='/about' passHref prefetch={false}>
44
+ <Link>Link without prefetch</Link>
45
+ </PageLink>
46
+ )
47
+ }
48
+ ```
49
+
50
+ ```tsx
51
+ import { NextLink } from '@graphcommerce/next-ui'
52
+ import { Link } from '@mui/material'
53
+
54
+ function MyComponent() {
55
+ return (
56
+ <Link href='/about' component={NextLink} prefetch={false}>
57
+ Link without prefetch
58
+ </Link>
59
+ )
60
+ }
61
+ ```
62
+
63
+ ### Upgrading a Button that uses component='a'
64
+
65
+ ```tsx
66
+ import PageLink from 'next/link'
67
+ import { Link } from '@mui/material'
68
+
69
+ function MyComponent() {
70
+ return (
71
+ <PageLink href='/about' passHref>
72
+ <Button component='a'>Link with component='a'</Link>
73
+ </PageLink>
74
+ )
75
+ }
76
+ ```
77
+
78
+ ```tsx
79
+ import { Link } from '@mui/material'
80
+
81
+ function MyComponent() {
82
+ return (
83
+ <Button href='/about' prefetch={false}>
84
+ component='a' isn't needed
85
+ </Button>
86
+ )
87
+ }
88
+ ```
89
+
90
+ Note: If there is a case where this is required, make sure you use
91
+ `component={NextLink}` instead of `component='a'`. A global search through the
92
+ codebase will show you where this is used.
93
+
94
+ ```tsx
95
+ import { NextLink } from '@graphcommerce/next-ui'
96
+ import { Link } from '@mui/material'
97
+
98
+ function MyComponent() {
99
+ return (
100
+ <Button href='/about' component={NextLink} prefetch={false}>
101
+ component='a' isn't needed
102
+ </Button>
103
+ )
104
+ }
105
+ ```
106
+
107
+ ## Upgrading a non button components like Chip, Box, etc.
108
+
109
+ ```tsx
110
+ import PageLink from 'next/link'
111
+ import { Link } from '@mui/material'
112
+
113
+ function MyComponent() {
114
+ return (
115
+ <PageLink href='/about' passHref>
116
+ <Chip>Chip</Link>
117
+ </PageLink>
118
+ )
119
+ }
120
+ ```
121
+
122
+ ```tsx
123
+ import { NextLink } from '@graphcommerce/next-ui'
124
+ import { Link } from '@mui/material'
125
+
126
+ function MyComponent() {
127
+ return (
128
+ <Chip href="/about" component={NextLink}>Chip</Link>
129
+ )
130
+ }
131
+ ```
132
+
133
+ ## Further reading
134
+
135
+ - [Upgrading](./readme.md)
@@ -100,7 +100,11 @@ you commit, make sure to delete all the .rej files:
100
100
  find . -type f -name '*.rej' -delete
101
101
  ```
102
102
 
103
- After resolving the diff issues, run and validate your local environment:
103
+ After resolving the diff issues, manually process upgrade instructions:
104
+
105
+ - [Upgrading to GraphCommerce 5 to 6](./graphcommerce-5-to-6.md)
106
+
107
+ Run and validate your local environment:
104
108
 
105
109
  - `yarn codegen` should run without errors
106
110
  - `yarn tsc:lint` should run without errors