@shopify/cli-hydrogen 6.1.0 → 7.0.0
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/dist/commands/hydrogen/build.js +40 -78
- package/dist/commands/hydrogen/codegen.js +8 -3
- package/dist/commands/hydrogen/deploy.js +107 -35
- package/dist/commands/hydrogen/deploy.test.js +83 -13
- package/dist/commands/hydrogen/dev.js +30 -15
- package/dist/commands/hydrogen/init.js +1 -1
- package/dist/commands/hydrogen/init.test.js +155 -53
- package/dist/commands/hydrogen/link.js +5 -21
- package/dist/commands/hydrogen/link.test.js +10 -10
- package/dist/commands/hydrogen/preview.js +7 -6
- package/dist/commands/hydrogen/setup.js +0 -4
- package/dist/commands/hydrogen/setup.test.js +0 -1
- package/dist/commands/hydrogen/upgrade.js +15 -0
- package/dist/generator-templates/starter/.graphqlrc.yml +12 -1
- package/dist/generator-templates/starter/CHANGELOG.md +56 -0
- package/dist/generator-templates/starter/README.md +23 -0
- package/dist/generator-templates/starter/app/components/Cart.tsx +1 -1
- package/dist/generator-templates/starter/app/components/Header.tsx +5 -1
- package/dist/generator-templates/starter/app/components/Layout.tsx +1 -1
- package/dist/generator-templates/starter/app/components/Search.tsx +1 -1
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts +61 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerDetailsQuery.ts +39 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrderQuery.ts +87 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerOrdersQuery.ts +58 -0
- package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts +24 -0
- package/dist/generator-templates/starter/app/lib/fragments.ts +102 -0
- package/dist/generator-templates/starter/app/lib/session.ts +67 -0
- package/dist/generator-templates/starter/app/root.tsx +11 -45
- package/dist/generator-templates/starter/app/routes/account.$.tsx +8 -4
- package/dist/generator-templates/starter/app/routes/account._index.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account.addresses.tsx +215 -206
- package/dist/generator-templates/starter/app/routes/account.orders.$id.tsx +56 -163
- package/dist/generator-templates/starter/app/routes/account.orders._index.tsx +32 -109
- package/dist/generator-templates/starter/app/routes/account.profile.tsx +40 -180
- package/dist/generator-templates/starter/app/routes/account.tsx +20 -135
- package/dist/generator-templates/starter/app/routes/account_.authorize.tsx +5 -0
- package/dist/generator-templates/starter/app/routes/account_.login.tsx +3 -140
- package/dist/generator-templates/starter/app/routes/account_.logout.tsx +5 -24
- package/dist/generator-templates/starter/app/routes/cart.tsx +7 -5
- package/dist/generator-templates/starter/app/routes/collections.$handle.tsx +1 -1
- package/dist/generator-templates/starter/app/routes/products.$handle.tsx +2 -2
- package/dist/generator-templates/starter/app/routes/search.tsx +1 -1
- package/dist/generator-templates/starter/customer-accountapi.generated.d.ts +506 -0
- package/dist/generator-templates/starter/package.json +11 -11
- package/dist/generator-templates/starter/remix.config.js +4 -0
- package/dist/generator-templates/starter/remix.env.d.ts +4 -11
- package/dist/generator-templates/starter/server.ts +24 -167
- package/dist/generator-templates/starter/storefrontapi.generated.d.ts +104 -881
- package/dist/hooks/init.js +4 -4
- package/dist/lib/auth.js +5 -10
- package/dist/lib/build.js +6 -1
- package/dist/lib/bundle/analyzer.js +36 -26
- package/dist/lib/codegen.js +58 -18
- package/dist/lib/defer.js +12 -0
- package/dist/lib/file.js +52 -3
- package/dist/lib/flags.js +15 -8
- package/dist/lib/get-oxygen-deployment-data.test.js +4 -2
- package/dist/lib/graphql/admin/client.test.js +2 -2
- package/dist/lib/graphql/admin/get-oxygen-data.js +1 -0
- package/dist/lib/log.js +31 -14
- package/dist/lib/mini-oxygen/index.js +4 -5
- package/dist/lib/mini-oxygen/mini-oxygen.test.js +214 -0
- package/dist/lib/mini-oxygen/node.js +4 -2
- package/dist/lib/mini-oxygen/workerd-inspector-logs.js +2 -2
- package/dist/lib/mini-oxygen/workerd.js +27 -10
- package/dist/lib/missing-routes.js +6 -3
- package/dist/lib/onboarding/common.js +40 -9
- package/dist/lib/onboarding/local.js +19 -11
- package/dist/lib/onboarding/remote.js +48 -28
- package/dist/lib/request-events.js +65 -31
- package/dist/lib/setups/css/assets.js +1 -46
- package/dist/lib/setups/css/css-modules.js +3 -2
- package/dist/lib/setups/css/postcss.js +4 -2
- package/dist/lib/setups/css/tailwind.js +4 -2
- package/dist/lib/setups/css/vanilla-extract.js +3 -2
- package/dist/lib/setups/i18n/replacers.test.js +54 -38
- package/dist/lib/template-diff.js +89 -0
- package/dist/lib/template-downloader.js +3 -2
- package/dist/lib/transpile/project.js +1 -1
- package/dist/virtual-routes/assets/debug-network.css +592 -0
- package/dist/virtual-routes/assets/favicon-dark.svg +20 -0
- package/dist/virtual-routes/components/FlameChartWrapper.jsx +8 -10
- package/dist/virtual-routes/components/IconClose.jsx +38 -0
- package/dist/virtual-routes/components/IconDiscard.jsx +44 -0
- package/dist/virtual-routes/components/RequestDetails.jsx +179 -0
- package/dist/virtual-routes/components/RequestTable.jsx +92 -0
- package/dist/virtual-routes/components/RequestWaterfall.jsx +151 -0
- package/dist/virtual-routes/lib/useDebugNetworkServer.jsx +176 -0
- package/dist/virtual-routes/routes/subrequest-profiler.jsx +243 -0
- package/oclif.manifest.json +54 -61
- package/package.json +14 -11
- package/dist/generator-templates/starter/app/routes/account_.activate.$id.$activationToken.tsx +0 -161
- package/dist/generator-templates/starter/app/routes/account_.recover.tsx +0 -129
- package/dist/generator-templates/starter/app/routes/account_.register.tsx +0 -207
- package/dist/generator-templates/starter/app/routes/account_.reset.$id.$resetToken.tsx +0 -136
- package/dist/virtual-routes/routes/debug-network.jsx +0 -289
- /package/dist/generator-templates/starter/app/{utils.ts → lib/variants.ts} +0 -0
|
@@ -103,6 +103,7 @@ async function runUpgrade({
|
|
|
103
103
|
});
|
|
104
104
|
const instrunctionsFilePath = await instrunctionsFilePathPromise;
|
|
105
105
|
await displayUpgradeSummary({
|
|
106
|
+
appPath,
|
|
106
107
|
currentVersion,
|
|
107
108
|
instrunctionsFilePath,
|
|
108
109
|
selectedRelease
|
|
@@ -456,6 +457,7 @@ async function promptUpgradeOptions(currentVersion, availableUpgrades) {
|
|
|
456
457
|
});
|
|
457
458
|
}
|
|
458
459
|
async function displayUpgradeSummary({
|
|
460
|
+
appPath,
|
|
459
461
|
currentVersion,
|
|
460
462
|
selectedRelease,
|
|
461
463
|
instrunctionsFilePath
|
|
@@ -482,6 +484,7 @@ ${releaseNotesUrl}`);
|
|
|
482
484
|
const upgradedDependenciesOnly = currentPinnedVersion === selectedPinnedVersion;
|
|
483
485
|
const fromToMsg = `${currentPinnedVersion} \u2192 ${selectedPinnedVersion}`;
|
|
484
486
|
const headline = upgradedDependenciesOnly ? `You've have upgraded Hydrogen ${selectedPinnedVersion} dependencies` : `You've have upgraded from ${fromToMsg}`;
|
|
487
|
+
const packageManager = await getPackageManager(appPath);
|
|
485
488
|
return renderSuccess({
|
|
486
489
|
headline,
|
|
487
490
|
// @ts-ignore we know that filter(Boolean) will always return an array
|
|
@@ -505,6 +508,18 @@ ${releaseNotesUrl}`);
|
|
|
505
508
|
}
|
|
506
509
|
}
|
|
507
510
|
]
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
title: "Undo these upgrades?",
|
|
514
|
+
body: [
|
|
515
|
+
{
|
|
516
|
+
list: {
|
|
517
|
+
items: [
|
|
518
|
+
`Run \`git restore . && git clean -df && ${packageManager} i\``
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
]
|
|
508
523
|
}
|
|
509
524
|
].filter(Boolean)
|
|
510
525
|
});
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
projects:
|
|
2
|
+
default:
|
|
3
|
+
schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
4
|
+
documents:
|
|
5
|
+
- '!*.d.ts'
|
|
6
|
+
- '*.{ts,tsx,js,jsx}'
|
|
7
|
+
- 'app/**/*.{ts,tsx,js,jsx}'
|
|
8
|
+
- '!app/graphql/**/*.{ts,tsx,js,jsx}'
|
|
9
|
+
customer-account:
|
|
10
|
+
schema: 'node_modules/@shopify/hydrogen/customer-account.schema.json'
|
|
11
|
+
documents:
|
|
12
|
+
- 'app/graphql/customer-account/**/*.{ts,tsx,js,jsx}'
|
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# skeleton
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Use new parameters introduced in Storefront API v2024-01 to fix redirection to the product's default variant when there are unknown query params in the URL. ([#1642](https://github.com/Shopify/hydrogen/pull/1642)) by [@wizardlyhel](https://github.com/wizardlyhel)
|
|
8
|
+
|
|
9
|
+
```diff
|
|
10
|
+
- selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions) {
|
|
11
|
+
+ selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions, ignoreUnknownOptions: true, caseInsensitiveMatch: true) {
|
|
12
|
+
...ProductVariant
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Update the GraphQL config in `.graphqlrc.yml` to use the more modern `projects` structure: ([#1577](https://github.com/Shopify/hydrogen/pull/1577)) by [@frandiox](https://github.com/frandiox)
|
|
17
|
+
|
|
18
|
+
```diff
|
|
19
|
+
-schema: node_modules/@shopify/hydrogen/storefront.schema.json
|
|
20
|
+
+projects:
|
|
21
|
+
+ default:
|
|
22
|
+
+ schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
This allows you to add additional projects to the GraphQL config, such as third party CMS schemas.
|
|
26
|
+
|
|
27
|
+
Also, you can modify the document paths used for the Storefront API queries. This is useful if you have a large codebase and want to exclude certain files from being used for codegen or other GraphQL utilities:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
projects:
|
|
31
|
+
default:
|
|
32
|
+
schema: 'node_modules/@shopify/hydrogen/storefront.schema.json'
|
|
33
|
+
documents:
|
|
34
|
+
- '!*.d.ts'
|
|
35
|
+
- '*.{ts,tsx,js,jsx}'
|
|
36
|
+
- 'app/**/*.{ts,tsx,js,jsx}'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- Improve resiliency of `HydrogenSession` ([#1583](https://github.com/Shopify/hydrogen/pull/1583)) by [@blittle](https://github.com/blittle)
|
|
40
|
+
|
|
41
|
+
- Update `@shopify/cli` dependency in `package.json`: ([#1579](https://github.com/Shopify/hydrogen/pull/1579)) by [@frandiox](https://github.com/frandiox)
|
|
42
|
+
|
|
43
|
+
```diff
|
|
44
|
+
- "@shopify/cli": "3.51.0",
|
|
45
|
+
+ "@shopify/cli": "3.52.0",
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- - Update example and template Remix versions to `^2.5.1` ([#1639](https://github.com/Shopify/hydrogen/pull/1639)) by [@wizardlyhel](https://github.com/wizardlyhel)
|
|
49
|
+
|
|
50
|
+
- Enable Remix future flags:
|
|
51
|
+
- [`v3_fetcherPersist`](https://remix.run/docs/en/main/hooks/use-fetchers#additional-resources)
|
|
52
|
+
- [`v3_relativeSplatpath`](https://remix.run/docs/en/main/hooks/use-resolved-path#splat-paths)
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [[`810f48cf`](https://github.com/Shopify/hydrogen/commit/810f48cf5d55f0cfcac6e01fe481db8c76e77cd2), [`8c477cb5`](https://github.com/Shopify/hydrogen/commit/8c477cb565c3e018bf4e13bad01804c21611fb8a), [`42ac4138`](https://github.com/Shopify/hydrogen/commit/42ac4138553c7e1a438b075c4f9cb781edffebc4), [`0241b7d2`](https://github.com/Shopify/hydrogen/commit/0241b7d2dcb887d259ce9033aca356d391bc07df), [`6a897586`](https://github.com/Shopify/hydrogen/commit/6a897586bd0908db90736921d11e4b6bdf29c912), [`0ff63bed`](https://github.com/Shopify/hydrogen/commit/0ff63bed840f5b8a5eb9968b67bd9a5a57099253), [`6bc1d61c`](https://github.com/Shopify/hydrogen/commit/6bc1d61c17a9c9be13f52338d2ab940e64e73495), [`eb0f4bcc`](https://github.com/Shopify/hydrogen/commit/eb0f4bccb57966a00ecb2b88d17dd694599da340), [`400bfee6`](https://github.com/Shopify/hydrogen/commit/400bfee6836a51c6ab5e4804e8b1e9ad48856dcb), [`a69c21ca`](https://github.com/Shopify/hydrogen/commit/a69c21caa15dfedb88afd50f262f17bf86f74836), [`970073e7`](https://github.com/Shopify/hydrogen/commit/970073e78258880505e0de563136b5379d5d24af), [`772118ca`](https://github.com/Shopify/hydrogen/commit/772118ca6aefbd47841fffc6ce42856c2dc779bd), [`335375a6`](https://github.com/Shopify/hydrogen/commit/335375a6b1a512f70e169a82bc87a8392dc8c92c), [`335371ce`](https://github.com/Shopify/hydrogen/commit/335371ceb6e1bd5aebb6104f131d3f22798a245f), [`94509b75`](https://github.com/Shopify/hydrogen/commit/94509b750afefd686971198ed86277e2c70f3176), [`36d6fa2c`](https://github.com/Shopify/hydrogen/commit/36d6fa2c4fa54ff79f06ef17aa41f60478977bc0), [`3e7b6e8a`](https://github.com/Shopify/hydrogen/commit/3e7b6e8a3bf66bad7fc0f9c224f1c163dbe3e288), [`cce65795`](https://github.com/Shopify/hydrogen/commit/cce6579580f849bec9a28cf575f7130ba3627f6b), [`9e3d88d4`](https://github.com/Shopify/hydrogen/commit/9e3d88d498efaa20fe23de9837e0f444180bc787), [`ca1161b2`](https://github.com/Shopify/hydrogen/commit/ca1161b29ad7b4d0838953782fb114d5fe82193a), [`92840e51`](https://github.com/Shopify/hydrogen/commit/92840e51820e5c7822f731affd3f591c0099be10), [`952fedf2`](https://github.com/Shopify/hydrogen/commit/952fedf27b869164550954d1c15f53b32ec02675), [`1bc053c9`](https://github.com/Shopify/hydrogen/commit/1bc053c94ba1be14ddc28be9eb70be7219b295d1)]:
|
|
55
|
+
- @shopify/hydrogen@2024.1.0
|
|
56
|
+
- @shopify/cli-hydrogen@7.0.0
|
|
57
|
+
- @shopify/remix-oxygen@2.0.3
|
|
58
|
+
|
|
3
59
|
## 1.0.1
|
|
4
60
|
|
|
5
61
|
### Patch Changes
|
|
@@ -38,3 +38,26 @@ npm run build
|
|
|
38
38
|
```bash
|
|
39
39
|
npm run dev
|
|
40
40
|
```
|
|
41
|
+
|
|
42
|
+
## Setup for using Customer Account API (`/account` section)
|
|
43
|
+
|
|
44
|
+
### Setup public domain using ngrok
|
|
45
|
+
|
|
46
|
+
1. Setup a [ngrok](https://ngrok.com/) account and add a permanent domain (ie. `https://<your-ngrok-domain>.app`).
|
|
47
|
+
1. Install the [ngrok CLI](https://ngrok.com/download) to use in terminal
|
|
48
|
+
1. Start ngrok using `ngrok http --domain=<your-ngrok-domain>.app 3000`
|
|
49
|
+
|
|
50
|
+
### Include public domain in Customer Account API settings
|
|
51
|
+
|
|
52
|
+
1. Go to your Shopify admin => `Hydrogen` or `Headless` app/channel => Customer Account API => Application setup
|
|
53
|
+
1. Edit `Callback URI(s)` to include `https://<your-ngrok-domain>.app/account/authorize`
|
|
54
|
+
1. Edit `Javascript origin(s)` to include your public domain `https://<your-ngrok-domain>.app` or keep it blank
|
|
55
|
+
1. Edit `Logout URI` to include your public domain `https://<your-ngrok-domain>.app` or keep it blank
|
|
56
|
+
|
|
57
|
+
### Prepare Environment variables
|
|
58
|
+
|
|
59
|
+
Run [`npx shopify hydrogen link`](https://shopify.dev/docs/custom-storefronts/hydrogen/cli#link) or [`npx shopify hydrogen env pull`](https://shopify.dev/docs/custom-storefronts/hydrogen/cli#env-pull) to link this app to your own test shop.
|
|
60
|
+
|
|
61
|
+
Alternatly, the values of the required environment varaibles "PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID" and "PUBLIC_CUSTOMER_ACCOUNT_API_URL" can be found in customer account api settings in the Hydrogen admin channel.
|
|
62
|
+
|
|
63
|
+
🗒️ Note that mock.shop doesn't supply these variables automatically.
|
|
@@ -2,7 +2,7 @@ import {CartForm, Image, Money} from '@shopify/hydrogen';
|
|
|
2
2
|
import type {CartLineUpdateInput} from '@shopify/hydrogen/storefront-api-types';
|
|
3
3
|
import {Link} from '@remix-run/react';
|
|
4
4
|
import type {CartApiQueryFragment} from 'storefrontapi.generated';
|
|
5
|
-
import {useVariantUrl} from '~/
|
|
5
|
+
import {useVariantUrl} from '~/lib/variants';
|
|
6
6
|
|
|
7
7
|
type CartLine = CartApiQueryFragment['lines']['nodes'][0];
|
|
8
8
|
|
|
@@ -93,7 +93,11 @@ function HeaderCtas({
|
|
|
93
93
|
<nav className="header-ctas" role="navigation">
|
|
94
94
|
<HeaderMenuMobileToggle />
|
|
95
95
|
<NavLink prefetch="intent" to="/account" style={activeLinkStyle}>
|
|
96
|
-
|
|
96
|
+
<Suspense fallback="Sign in">
|
|
97
|
+
<Await resolve={isLoggedIn} errorElement="Sign in">
|
|
98
|
+
{(isLoggedIn) => (isLoggedIn ? 'Account' : 'Sign in')}
|
|
99
|
+
</Await>
|
|
100
|
+
</Suspense>
|
|
97
101
|
</NavLink>
|
|
98
102
|
<SearchToggle />
|
|
99
103
|
<CartToggle cart={cart} />
|
|
@@ -211,7 +211,7 @@ function SearchResultArticleGrid({articles}: Pick<SearchQuery, 'articles'>) {
|
|
|
211
211
|
<div>
|
|
212
212
|
{articles?.nodes?.map((article) => (
|
|
213
213
|
<div className="search-results-item" key={article.id}>
|
|
214
|
-
<Link prefetch="intent" to={`/
|
|
214
|
+
<Link prefetch="intent" to={`/blogs/${article.handle}`}>
|
|
215
215
|
{article.title}
|
|
216
216
|
</Link>
|
|
217
217
|
</div>
|
package/dist/generator-templates/starter/app/graphql/customer-account/CustomerAddressMutations.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressUpdate
|
|
2
|
+
export const UPDATE_ADDRESS_MUTATION = `#graphql
|
|
3
|
+
mutation customerAddressUpdate(
|
|
4
|
+
$address: CustomerAddressInput!
|
|
5
|
+
$addressId: ID!
|
|
6
|
+
$defaultAddress: Boolean
|
|
7
|
+
) {
|
|
8
|
+
customerAddressUpdate(
|
|
9
|
+
address: $address
|
|
10
|
+
addressId: $addressId
|
|
11
|
+
defaultAddress: $defaultAddress
|
|
12
|
+
) {
|
|
13
|
+
customerAddress {
|
|
14
|
+
id
|
|
15
|
+
}
|
|
16
|
+
userErrors {
|
|
17
|
+
code
|
|
18
|
+
field
|
|
19
|
+
message
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
` as const;
|
|
24
|
+
|
|
25
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressDelete
|
|
26
|
+
export const DELETE_ADDRESS_MUTATION = `#graphql
|
|
27
|
+
mutation customerAddressDelete(
|
|
28
|
+
$addressId: ID!,
|
|
29
|
+
) {
|
|
30
|
+
customerAddressDelete(addressId: $addressId) {
|
|
31
|
+
deletedAddressId
|
|
32
|
+
userErrors {
|
|
33
|
+
code
|
|
34
|
+
field
|
|
35
|
+
message
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
` as const;
|
|
40
|
+
|
|
41
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/mutations/customerAddressCreate
|
|
42
|
+
export const CREATE_ADDRESS_MUTATION = `#graphql
|
|
43
|
+
mutation customerAddressCreate(
|
|
44
|
+
$address: CustomerAddressInput!
|
|
45
|
+
$defaultAddress: Boolean
|
|
46
|
+
) {
|
|
47
|
+
customerAddressCreate(
|
|
48
|
+
address: $address
|
|
49
|
+
defaultAddress: $defaultAddress
|
|
50
|
+
) {
|
|
51
|
+
customerAddress {
|
|
52
|
+
id
|
|
53
|
+
}
|
|
54
|
+
userErrors {
|
|
55
|
+
code
|
|
56
|
+
field
|
|
57
|
+
message
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
` as const;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/objects/Customer
|
|
2
|
+
export const CUSTOMER_FRAGMENT = `#graphql
|
|
3
|
+
fragment Customer on Customer {
|
|
4
|
+
firstName
|
|
5
|
+
lastName
|
|
6
|
+
defaultAddress {
|
|
7
|
+
...Address
|
|
8
|
+
}
|
|
9
|
+
addresses(first: 6) {
|
|
10
|
+
nodes {
|
|
11
|
+
...Address
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
fragment Address on CustomerAddress {
|
|
16
|
+
id
|
|
17
|
+
formatted
|
|
18
|
+
firstName
|
|
19
|
+
lastName
|
|
20
|
+
company
|
|
21
|
+
address1
|
|
22
|
+
address2
|
|
23
|
+
territoryCode
|
|
24
|
+
zoneCode
|
|
25
|
+
city
|
|
26
|
+
zip
|
|
27
|
+
phoneNumber
|
|
28
|
+
}
|
|
29
|
+
` as const;
|
|
30
|
+
|
|
31
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/queries/customer
|
|
32
|
+
export const CUSTOMER_DETAILS_QUERY = `#graphql
|
|
33
|
+
query CustomerDetails {
|
|
34
|
+
customer {
|
|
35
|
+
...Customer
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
${CUSTOMER_FRAGMENT}
|
|
39
|
+
` as const;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/customer/latest/queries/order
|
|
2
|
+
export const CUSTOMER_ORDER_QUERY = `#graphql
|
|
3
|
+
fragment OrderMoney on MoneyV2 {
|
|
4
|
+
amount
|
|
5
|
+
currencyCode
|
|
6
|
+
}
|
|
7
|
+
fragment DiscountApplication on DiscountApplication {
|
|
8
|
+
value {
|
|
9
|
+
__typename
|
|
10
|
+
... on MoneyV2 {
|
|
11
|
+
...OrderMoney
|
|
12
|
+
}
|
|
13
|
+
... on PricingPercentageValue {
|
|
14
|
+
percentage
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
fragment OrderLineItemFull on LineItem {
|
|
19
|
+
id
|
|
20
|
+
title
|
|
21
|
+
quantity
|
|
22
|
+
price {
|
|
23
|
+
...OrderMoney
|
|
24
|
+
}
|
|
25
|
+
discountAllocations {
|
|
26
|
+
allocatedAmount {
|
|
27
|
+
...OrderMoney
|
|
28
|
+
}
|
|
29
|
+
discountApplication {
|
|
30
|
+
...DiscountApplication
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
totalDiscount {
|
|
34
|
+
...OrderMoney
|
|
35
|
+
}
|
|
36
|
+
image {
|
|
37
|
+
altText
|
|
38
|
+
height
|
|
39
|
+
url
|
|
40
|
+
id
|
|
41
|
+
width
|
|
42
|
+
}
|
|
43
|
+
variantTitle
|
|
44
|
+
}
|
|
45
|
+
fragment Order on Order {
|
|
46
|
+
id
|
|
47
|
+
name
|
|
48
|
+
statusPageUrl
|
|
49
|
+
processedAt
|
|
50
|
+
fulfillments(first: 1) {
|
|
51
|
+
nodes {
|
|
52
|
+
status
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
totalTax {
|
|
56
|
+
...OrderMoney
|
|
57
|
+
}
|
|
58
|
+
totalPrice {
|
|
59
|
+
...OrderMoney
|
|
60
|
+
}
|
|
61
|
+
subtotal {
|
|
62
|
+
...OrderMoney
|
|
63
|
+
}
|
|
64
|
+
shippingAddress {
|
|
65
|
+
name
|
|
66
|
+
formatted(withName: true)
|
|
67
|
+
formattedArea
|
|
68
|
+
}
|
|
69
|
+
discountApplications(first: 100) {
|
|
70
|
+
nodes {
|
|
71
|
+
...DiscountApplication
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
lineItems(first: 100) {
|
|
75
|
+
nodes {
|
|
76
|
+
...OrderLineItemFull
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
query Order($orderId: ID!) {
|
|
81
|
+
order(id: $orderId) {
|
|
82
|
+
... on Order {
|
|
83
|
+
...Order
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
` as const;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// https://shopify.dev/docs/api/customer/latest/objects/Order
|
|
2
|
+
export const ORDER_ITEM_FRAGMENT = `#graphql
|
|
3
|
+
fragment OrderItem on Order {
|
|
4
|
+
totalPrice {
|
|
5
|
+
amount
|
|
6
|
+
currencyCode
|
|
7
|
+
}
|
|
8
|
+
financialStatus
|
|
9
|
+
fulfillments(first: 1) {
|
|
10
|
+
nodes {
|
|
11
|
+
status
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
id
|
|
15
|
+
number
|
|
16
|
+
processedAt
|
|
17
|
+
}
|
|
18
|
+
` as const;
|
|
19
|
+
|
|
20
|
+
// https://shopify.dev/docs/api/customer/latest/objects/Customer
|
|
21
|
+
export const CUSTOMER_ORDERS_FRAGMENT = `#graphql
|
|
22
|
+
fragment CustomerOrders on Customer {
|
|
23
|
+
orders(
|
|
24
|
+
sortKey: PROCESSED_AT,
|
|
25
|
+
reverse: true,
|
|
26
|
+
first: $first,
|
|
27
|
+
last: $last,
|
|
28
|
+
before: $startCursor,
|
|
29
|
+
after: $endCursor
|
|
30
|
+
) {
|
|
31
|
+
nodes {
|
|
32
|
+
...OrderItem
|
|
33
|
+
}
|
|
34
|
+
pageInfo {
|
|
35
|
+
hasPreviousPage
|
|
36
|
+
hasNextPage
|
|
37
|
+
endCursor
|
|
38
|
+
startCursor
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
${ORDER_ITEM_FRAGMENT}
|
|
43
|
+
` as const;
|
|
44
|
+
|
|
45
|
+
// https://shopify.dev/docs/api/customer/latest/queries/customer
|
|
46
|
+
export const CUSTOMER_ORDERS_QUERY = `#graphql
|
|
47
|
+
${CUSTOMER_ORDERS_FRAGMENT}
|
|
48
|
+
query CustomerOrders(
|
|
49
|
+
$endCursor: String
|
|
50
|
+
$first: Int
|
|
51
|
+
$last: Int
|
|
52
|
+
$startCursor: String
|
|
53
|
+
) {
|
|
54
|
+
customer {
|
|
55
|
+
...CustomerOrders
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
` as const;
|
package/dist/generator-templates/starter/app/graphql/customer-account/CustomerUpdateMutation.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const CUSTOMER_UPDATE_MUTATION = `#graphql
|
|
2
|
+
# https://shopify.dev/docs/api/customer/latest/mutations/customerUpdate
|
|
3
|
+
mutation customerUpdate(
|
|
4
|
+
$customer: CustomerUpdateInput!
|
|
5
|
+
){
|
|
6
|
+
customerUpdate(input: $customer) {
|
|
7
|
+
customer {
|
|
8
|
+
firstName
|
|
9
|
+
lastName
|
|
10
|
+
emailAddress {
|
|
11
|
+
emailAddress
|
|
12
|
+
}
|
|
13
|
+
phoneNumber {
|
|
14
|
+
phoneNumber
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
userErrors {
|
|
18
|
+
code
|
|
19
|
+
field
|
|
20
|
+
message
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
` as const;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// NOTE: https://shopify.dev/docs/api/storefront/latest/queries/cart
|
|
2
|
+
export const CART_QUERY_FRAGMENT = `#graphql
|
|
3
|
+
fragment Money on MoneyV2 {
|
|
4
|
+
currencyCode
|
|
5
|
+
amount
|
|
6
|
+
}
|
|
7
|
+
fragment CartLine on CartLine {
|
|
8
|
+
id
|
|
9
|
+
quantity
|
|
10
|
+
attributes {
|
|
11
|
+
key
|
|
12
|
+
value
|
|
13
|
+
}
|
|
14
|
+
cost {
|
|
15
|
+
totalAmount {
|
|
16
|
+
...Money
|
|
17
|
+
}
|
|
18
|
+
amountPerQuantity {
|
|
19
|
+
...Money
|
|
20
|
+
}
|
|
21
|
+
compareAtAmountPerQuantity {
|
|
22
|
+
...Money
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
merchandise {
|
|
26
|
+
... on ProductVariant {
|
|
27
|
+
id
|
|
28
|
+
availableForSale
|
|
29
|
+
compareAtPrice {
|
|
30
|
+
...Money
|
|
31
|
+
}
|
|
32
|
+
price {
|
|
33
|
+
...Money
|
|
34
|
+
}
|
|
35
|
+
requiresShipping
|
|
36
|
+
title
|
|
37
|
+
image {
|
|
38
|
+
id
|
|
39
|
+
url
|
|
40
|
+
altText
|
|
41
|
+
width
|
|
42
|
+
height
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
product {
|
|
46
|
+
handle
|
|
47
|
+
title
|
|
48
|
+
id
|
|
49
|
+
}
|
|
50
|
+
selectedOptions {
|
|
51
|
+
name
|
|
52
|
+
value
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
fragment CartApiQuery on Cart {
|
|
58
|
+
id
|
|
59
|
+
checkoutUrl
|
|
60
|
+
totalQuantity
|
|
61
|
+
buyerIdentity {
|
|
62
|
+
countryCode
|
|
63
|
+
customer {
|
|
64
|
+
id
|
|
65
|
+
email
|
|
66
|
+
firstName
|
|
67
|
+
lastName
|
|
68
|
+
displayName
|
|
69
|
+
}
|
|
70
|
+
email
|
|
71
|
+
phone
|
|
72
|
+
}
|
|
73
|
+
lines(first: $numCartLines) {
|
|
74
|
+
nodes {
|
|
75
|
+
...CartLine
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
cost {
|
|
79
|
+
subtotalAmount {
|
|
80
|
+
...Money
|
|
81
|
+
}
|
|
82
|
+
totalAmount {
|
|
83
|
+
...Money
|
|
84
|
+
}
|
|
85
|
+
totalDutyAmount {
|
|
86
|
+
...Money
|
|
87
|
+
}
|
|
88
|
+
totalTaxAmount {
|
|
89
|
+
...Money
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
note
|
|
93
|
+
attributes {
|
|
94
|
+
key
|
|
95
|
+
value
|
|
96
|
+
}
|
|
97
|
+
discountCodes {
|
|
98
|
+
code
|
|
99
|
+
applicable
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
` as const;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {HydrogenSession} from '@shopify/hydrogen';
|
|
2
|
+
import {
|
|
3
|
+
createCookieSessionStorage,
|
|
4
|
+
type SessionStorage,
|
|
5
|
+
type Session,
|
|
6
|
+
} from '@shopify/remix-oxygen';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* This is a custom session implementation for your Hydrogen shop.
|
|
10
|
+
* Feel free to customize it to your needs, add helper methods, or
|
|
11
|
+
* swap out the cookie-based implementation with something else!
|
|
12
|
+
*/
|
|
13
|
+
export class AppSession implements HydrogenSession {
|
|
14
|
+
#sessionStorage;
|
|
15
|
+
#session;
|
|
16
|
+
|
|
17
|
+
constructor(sessionStorage: SessionStorage, session: Session) {
|
|
18
|
+
this.#sessionStorage = sessionStorage;
|
|
19
|
+
this.#session = session;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static async init(request: Request, secrets: string[]) {
|
|
23
|
+
const storage = createCookieSessionStorage({
|
|
24
|
+
cookie: {
|
|
25
|
+
name: 'session',
|
|
26
|
+
httpOnly: true,
|
|
27
|
+
path: '/',
|
|
28
|
+
sameSite: 'lax',
|
|
29
|
+
secrets,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const session = await storage
|
|
34
|
+
.getSession(request.headers.get('Cookie'))
|
|
35
|
+
.catch(() => storage.getSession());
|
|
36
|
+
|
|
37
|
+
return new this(storage, session);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get has() {
|
|
41
|
+
return this.#session.has;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
get get() {
|
|
45
|
+
return this.#session.get;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get flash() {
|
|
49
|
+
return this.#session.flash;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get unset() {
|
|
53
|
+
return this.#session.unset;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get set() {
|
|
57
|
+
return this.#session.set;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
destroy() {
|
|
61
|
+
return this.#sessionStorage.destroySession(this.#session);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
commit() {
|
|
65
|
+
return this.#sessionStorage.commitSession(this.#session);
|
|
66
|
+
}
|
|
67
|
+
}
|