@graphcommerce/docs 6.0.0-canary.27 → 6.0.0-canary.29

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,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.0.0-canary.29
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1828](https://github.com/graphcommerce-org/graphcommerce/pull/1828) [`3df85faf1`](https://github.com/graphcommerce-org/graphcommerce/commit/3df85faf189b95e2c7d9c3fc756474fcafb1c8b4) - Added new `productRoute` configuration to create freedom in the actual product route used (default: /p/). Simplified redirects from legacy product routes to new routes by creating redirects. ([@paales](https://github.com/paales))
8
+
9
+ ## 6.0.0-canary.28
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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))
14
+
3
15
  ## 6.0.0-canary.27
4
16
 
5
17
  ## 6.0.0-canary.26
@@ -1,9 +1,83 @@
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
+ ## Exporting current configuration to environment variables
51
+
52
+ You can export configuration by running `yarn graphcommerce export-config`
53
+
54
+ ## Extending the configuration in your project
55
+
56
+ Create a graphql/Config.graphqls file in your project and extend the GraphCommerceConfig, GraphCommerceI18nConfig inputs to add configuration.
57
+
58
+ ```graphql
59
+ extend input GraphCommerceConfig {
60
+ myOptionalBoolean: Boolean
61
+ myRequiredBoolean: Boolean!
62
+ myOptionalString: String
63
+ myRequiredString: String!
64
+ myOptionalInt: Int
65
+ myRequiredInt: Int!
66
+ myOptionalFloat: Float
67
+ myRequiredFloat: Float!
68
+ }
69
+ extend input GraphCommerceI18nConfig {
70
+ myField: Boolean
71
+ }
72
+ ```
73
+
74
+ ## All configuration values
75
+
76
+ Below is a list of all possible configurations that can be set by GraphCommerce.
77
+
78
+ ### GraphCommerceConfig
79
+
80
+ #### `canonicalBaseUrl: String!`
7
81
 
8
82
  The canonical base URL is used for SEO purposes.
9
83
 
@@ -12,47 +86,30 @@ Examples:
12
86
  - https://example.com/en
13
87
  - https://example.com/en-US
14
88
 
15
- ### `hygraphEndpoint: String!`
89
+ #### `hygraphEndpoint: String!`
16
90
 
17
91
  The HyGraph endpoint.
18
92
 
19
93
  Project settings -> API Access -> High Performance Read-only Content API
20
94
 
21
- ### `i18n: [GraphCommerceI18nConfig!]!`
95
+ #### `i18n: [[GraphCommerceI18nConfig](#GraphCommerceI18nConfig)!]!`
22
96
 
23
97
  All i18n configuration for the project
24
98
 
25
- ### `magentoEndpoint: String!`
99
+ #### `magentoEndpoint: String!`
26
100
 
27
101
  GraphQL Magento endpoint.
28
102
 
29
103
  Examples:
30
104
  - https://magento2.test/graphql
31
105
 
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`
106
+ #### `cartDisplayPricesInclTax: Boolean`
50
107
 
51
108
  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
109
 
53
110
  When Magento's StoreConfig adds this value, this can be replaced.
54
111
 
55
- ### `customerRequireEmailConfirmation: Boolean`
112
+ #### `customerRequireEmailConfirmation: Boolean`
56
113
 
57
114
  Due to a limitation in the GraphQL API of Magento 2, we need to know if the
58
115
  customer requires email confirmation.
@@ -60,11 +117,11 @@ customer requires email confirmation.
60
117
  This value should match Magento 2's configuration value for
61
118
  `customer/create_account/confirm` and should be removed once we can query
62
119
 
63
- ### `debug: GraphCommerceDebugConfig`
120
+ #### `debug: [GraphCommerceDebugConfig](#GraphCommerceDebugConfig)`
64
121
 
65
122
  Debug configuration for GraphCommerce
66
123
 
67
- ### `demoMode: Boolean`
124
+ #### `demoMode: Boolean`
68
125
 
69
126
  Enables some demo specific code that is probably not useful for a project:
70
127
 
@@ -72,7 +129,7 @@ Enables some demo specific code that is probably not useful for a project:
72
129
  - Adds "dominant_color" attribute swatches to the product list items.
73
130
  - Creates a big list items in the product list.
74
131
 
75
- ### `googleAnalyticsId: String`
132
+ #### `googleAnalyticsId: String`
76
133
 
77
134
  See https://support.google.com/analytics/answer/9539598?hl=en
78
135
 
@@ -80,50 +137,76 @@ Provide a value to enable Google Analytics for your store.
80
137
 
81
138
  To enable only for a specific locale, override the value in the i18n config.
82
139
 
83
- ### `googleRecaptchaKey: String`
140
+ #### `googleRecaptchaKey: String`
84
141
 
85
142
  Google reCAPTCHA key, get from https://developers.google.com/recaptcha/docs/v3
86
143
 
87
144
  This value is required even if you are configuring different values for each locale.
88
145
 
89
- ### `googleTagmanagerId: String`
146
+ #### `googleTagmanagerId: String`
90
147
 
91
148
  The Google Tagmanager ID to be used on the site.
92
149
 
93
150
  This value is required even if you are configuring different values for each locale.
94
151
 
95
- ### `limitSsg: Boolean`
152
+ #### `legacyProductRoute: Boolean`
153
+
154
+ On older versions of GraphCommerce products would use a product type specific route.
155
+
156
+ This should only be set to true if you use the /product/[url] AND /product/configurable/[url] routes.
157
+
158
+ @deprecated Will be removed in a future version. [migration](../upgrading/graphcommerce-5-to-6.md#product-routing-changes)
159
+
160
+ #### `limitSsg: Boolean`
96
161
 
97
162
  Limit the static generation of SSG when building
98
163
 
99
- ### `previewSecret: String`
164
+ #### `previewSecret: String`
100
165
 
101
166
  To enable next.js' preview mode, configure the secret you'd like to use.
102
167
 
103
- ### `wishlistHideForGuests: Boolean`
168
+ #### `productFiltersPro: Boolean`
169
+
170
+ Product filters with better UI for mobile and desktop.
171
+
172
+ @experimental This is an experimental feature and may change in the future.
173
+
174
+ #### `productRoute: String`
175
+
176
+ By default we route products to /p/[url] but you can change this to /product/[url] if you wish.
177
+
178
+ Default: '/p/'
179
+ Example: '/product/'
180
+
181
+ #### `robotsAllow: Boolean`
182
+
183
+ Allow the site to be indexed by search engines.
184
+ If false, the robots.txt file will be set to disallow all.
185
+
186
+ #### `wishlistHideForGuests: Boolean`
104
187
 
105
188
  Hide the wishlist functionality for guests.
106
189
 
107
- ### `wishlistIgnoreProductWishlistStatus: Boolean`
190
+ #### `wishlistIgnoreProductWishlistStatus: Boolean`
108
191
 
109
192
  Ignores wether a product is already in the wishlist, makes the toggle an add only.
110
193
 
111
- ## GraphCommerceDebugConfig
194
+ ### GraphCommerceDebugConfig
112
195
 
113
196
  Debug configuration for GraphCommerce
114
197
 
115
- ### `pluginStatus: Boolean`
198
+ #### `pluginStatus: Boolean`
116
199
 
117
200
  Reports which plugins are enabled or disabled.
118
201
 
119
- ### `webpackCircularDependencyPlugin: Boolean`
202
+ #### `webpackCircularDependencyPlugin: Boolean`
120
203
 
121
204
  Cyclic dependencies can cause memory issues and other strange bugs.
122
205
  This plugin will warn you when it detects a cyclic dependency.
123
206
 
124
207
  When running into memory issues, it can be useful to enable this plugin.
125
208
 
126
- ### `webpackDuplicatesPlugin: Boolean`
209
+ #### `webpackDuplicatesPlugin: Boolean`
127
210
 
128
211
  When updating packages it can happen that the same package is included with different versions in the same project.
129
212
 
@@ -131,15 +214,15 @@ Issues that this can cause are:
131
214
  - The same package is included multiple times in the bundle, increasing the bundle size.
132
215
  - The Typescript types of the package are not compatible with each other, causing Typescript errors.
133
216
 
134
- ## GraphCommerceI18nConfig
217
+ ### GraphCommerceI18nConfig
135
218
 
136
219
  All i18n configuration for the project
137
220
 
138
- ### `locale: String!`
221
+ #### `locale: String!`
139
222
 
140
223
  Must be a locale string https://www.unicode.org/reports/tr35/tr35-59/tr35.html#Identifiers
141
224
 
142
- ### `magentoStoreCode: String!`
225
+ #### `magentoStoreCode: String!`
143
226
 
144
227
  Magento store code.
145
228
 
@@ -150,7 +233,7 @@ Examples:
150
233
  - en-us
151
234
  - b2b-us
152
235
 
153
- ### `canonicalBaseUrl: String`
236
+ #### `canonicalBaseUrl: String`
154
237
 
155
238
  The canonical base URL is used for SEO purposes.
156
239
 
@@ -159,38 +242,38 @@ Examples:
159
242
  - https://example.com/en
160
243
  - https://example.com/en-US
161
244
 
162
- ### `cartDisplayPricesInclTax: Boolean`
245
+ #### `cartDisplayPricesInclTax: Boolean`
163
246
 
164
247
  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
248
 
166
- ### `defaultLocale: Boolean`
249
+ #### `defaultLocale: Boolean`
167
250
 
168
251
  There can only be one entry with defaultLocale set to true.
169
252
  - If there are more, the first one is used.
170
253
  - If there is none, the first entry is used.
171
254
 
172
- ### `domain: String`
255
+ #### `domain: String`
173
256
 
174
257
  Domain configuration, must be a domain https://tools.ietf.org/html/rfc3986
175
258
 
176
- ### `googleAnalyticsId: String`
259
+ #### `googleAnalyticsId: String`
177
260
 
178
261
  Configure different Google Analytics IDs for different locales.
179
262
 
180
263
  To disable for a specific locale, set the value to null.
181
264
 
182
- ### `googleRecaptchaKey: String`
265
+ #### `googleRecaptchaKey: String`
183
266
 
184
267
  Locale specific google reCAPTCHA key.
185
268
 
186
- ### `googleTagmanagerId: String`
269
+ #### `googleTagmanagerId: String`
187
270
 
188
271
  The Google Tagmanager ID to be used per locale.
189
272
 
190
- ### `hygraphLocales: [String!]`
273
+ #### `hygraphLocales: [String!]`
191
274
 
192
275
  Add a gcms-locales header to make sure queries return in a certain language, can be an array to define fallbacks.
193
276
 
194
- ### `linguiLocale: String`
277
+ #### `linguiLocale: String`
195
278
 
196
279
  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.
@@ -10,7 +10,8 @@ better performance.
10
10
  ## How are routes handled?
11
11
 
12
12
  - Products have a different URL structure: `/p/[url]`. e.g.
13
- `/p/my-product-url-key`.
13
+ `/p/my-product-url-key` (different route can be configured with
14
+ [productRoute config](../framework/config.md#productroute-string))
14
15
  - Categories use same URL structure: `/[...url]`. e.g. `/my/category/path`.
15
16
  - GraphCommerce does not use any URL suffixes. e.g. `.html`.
16
17
 
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.27",
5
+ "version": "6.0.0-canary.29",
6
6
  "sideEffects": true,
7
7
  "devDependencies": {
8
- "@graphcommerce/prettier-config-pwa": "6.0.0-canary.27"
8
+ "@graphcommerce/prettier-config-pwa": "6.0.0-canary.29"
9
9
  },
10
10
  "prettier": "@graphcommerce/prettier-config-pwa"
11
11
  }
@@ -0,0 +1,148 @@
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
+ ### Product routing changes
36
+
37
+ The route for the product has changed from `/product/[url]`,
38
+ `/product/configurable/[url]`, etc. to `/p/[url]` by default. This is a
39
+ singlular product page for all product types.
40
+
41
+ You can opt in to use the
42
+ [legacyProductRoute](../framework/config.md#legacyproductroute-boolean) to keep
43
+ the old behavior. This legacy routing will be removed in a future version.
44
+
45
+ You can also change the product route from `/p/[url]` to something else by
46
+ configuring [productRoute](../framework/config.md#productroute-string)
47
+
48
+ ### Upgrading a Link that uses next/link props
49
+
50
+ ```tsx
51
+ import PageLink from 'next/link'
52
+ import { Link } from '@mui/material'
53
+
54
+ function MyComponent() {
55
+ return (
56
+ <PageLink href='/about' passHref prefetch={false}>
57
+ <Link>Link without prefetch</Link>
58
+ </PageLink>
59
+ )
60
+ }
61
+ ```
62
+
63
+ ```tsx
64
+ import { NextLink } from '@graphcommerce/next-ui'
65
+ import { Link } from '@mui/material'
66
+
67
+ function MyComponent() {
68
+ return (
69
+ <Link href='/about' component={NextLink} prefetch={false}>
70
+ Link without prefetch
71
+ </Link>
72
+ )
73
+ }
74
+ ```
75
+
76
+ ### Upgrading a Button that uses component='a'
77
+
78
+ ```tsx
79
+ import PageLink from 'next/link'
80
+ import { Link } from '@mui/material'
81
+
82
+ function MyComponent() {
83
+ return (
84
+ <PageLink href='/about' passHref>
85
+ <Button component='a'>Link with component='a'</Link>
86
+ </PageLink>
87
+ )
88
+ }
89
+ ```
90
+
91
+ ```tsx
92
+ import { Link } from '@mui/material'
93
+
94
+ function MyComponent() {
95
+ return (
96
+ <Button href='/about' prefetch={false}>
97
+ component='a' isn't needed
98
+ </Button>
99
+ )
100
+ }
101
+ ```
102
+
103
+ Note: If there is a case where this is required, make sure you use
104
+ `component={NextLink}` instead of `component='a'`. A global search through the
105
+ codebase will show you where this is used.
106
+
107
+ ```tsx
108
+ import { NextLink } from '@graphcommerce/next-ui'
109
+ import { Link } from '@mui/material'
110
+
111
+ function MyComponent() {
112
+ return (
113
+ <Button href='/about' component={NextLink} prefetch={false}>
114
+ component='a' isn't needed
115
+ </Button>
116
+ )
117
+ }
118
+ ```
119
+
120
+ ## Upgrading a non button components like Chip, Box, etc.
121
+
122
+ ```tsx
123
+ import PageLink from 'next/link'
124
+ import { Link } from '@mui/material'
125
+
126
+ function MyComponent() {
127
+ return (
128
+ <PageLink href='/about' passHref>
129
+ <Chip>Chip</Link>
130
+ </PageLink>
131
+ )
132
+ }
133
+ ```
134
+
135
+ ```tsx
136
+ import { NextLink } from '@graphcommerce/next-ui'
137
+ import { Link } from '@mui/material'
138
+
139
+ function MyComponent() {
140
+ return (
141
+ <Chip href="/about" component={NextLink}>Chip</Link>
142
+ )
143
+ }
144
+ ```
145
+
146
+ ## Further reading
147
+
148
+ - [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