@shopify/hydrogen 0.18.0 → 0.21.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/config.d.ts +1 -0
  3. package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +1 -1
  4. package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +4 -7
  5. package/dist/esnext/components/CartLineImage/CartLineImage.client.js +1 -2
  6. package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +1 -1
  7. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +3 -1
  8. package/dist/esnext/components/CartProvider/CartProvider.client.js +22 -20
  9. package/dist/esnext/components/CartProvider/cart-queries.d.ts +10 -9
  10. package/dist/esnext/components/CartProvider/cart-queries.js +58 -743
  11. package/dist/esnext/components/CartProvider/hooks.client.js +4 -2
  12. package/dist/esnext/components/CartProvider/types.d.ts +2 -0
  13. package/dist/esnext/components/Image/Image.d.ts +78 -34
  14. package/dist/esnext/components/Image/Image.js +54 -51
  15. package/dist/esnext/components/Image/index.d.ts +1 -0
  16. package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +2 -15
  17. package/dist/esnext/components/LocalizationProvider/LocalizationContext.client.d.ts +0 -1
  18. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +2 -6
  19. package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +10 -4
  20. package/dist/esnext/components/MediaFile/MediaFile.d.ts +2 -2
  21. package/dist/esnext/components/MediaFile/MediaFile.js +2 -2
  22. package/dist/esnext/components/Money/Money.client.d.ts +11 -5
  23. package/dist/esnext/components/Money/Money.client.js +16 -3
  24. package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -2
  25. package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -2
  26. package/dist/esnext/components/Video/Video.d.ts +3 -3
  27. package/dist/esnext/components/Video/Video.js +7 -4
  28. package/dist/esnext/components/index.d.ts +0 -3
  29. package/dist/esnext/components/index.js +0 -3
  30. package/dist/esnext/entry-server.d.ts +13 -1
  31. package/dist/esnext/entry-server.js +18 -51
  32. package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
  33. package/dist/esnext/foundation/ServerStateProvider/ServerStateProvider.js +2 -0
  34. package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +1 -1
  35. package/dist/esnext/foundation/fetchSync/server/fetchSync.js +1 -1
  36. package/dist/esnext/foundation/useQuery/hooks.js +8 -9
  37. package/dist/esnext/foundation/useSession/useSession.d.ts +1 -1
  38. package/dist/esnext/foundation/useSession/useSession.js +1 -1
  39. package/dist/esnext/framework/Hydration/Html.js +3 -1
  40. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +1 -1
  41. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +2 -1
  42. package/dist/esnext/framework/Hydration/rsc.d.ts +0 -3
  43. package/dist/esnext/framework/Hydration/rsc.js +40 -12
  44. package/dist/esnext/framework/cache/in-memory.js +0 -6
  45. package/dist/esnext/framework/cache-sub-request.d.ts +17 -0
  46. package/dist/esnext/framework/cache-sub-request.js +64 -0
  47. package/dist/esnext/framework/cache.d.ts +6 -6
  48. package/dist/esnext/framework/cache.js +36 -33
  49. package/dist/esnext/framework/plugin.js +5 -30
  50. package/dist/esnext/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
  51. package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +25 -0
  52. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
  53. package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +73 -3
  54. package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
  55. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +6 -4
  56. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  57. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
  58. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
  59. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +35 -0
  60. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +1 -1
  61. package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +6 -3
  62. package/dist/esnext/hooks/useCountry/useCountry.d.ts +1 -11
  63. package/dist/esnext/hooks/useCountry/useCountry.js +1 -1
  64. package/dist/esnext/index.d.ts +4 -0
  65. package/dist/esnext/index.js +4 -0
  66. package/dist/esnext/node.d.ts +1 -0
  67. package/dist/esnext/node.js +1 -0
  68. package/dist/esnext/storefront-api-types.d.ts +5 -3
  69. package/dist/esnext/storefront-api-types.js +5 -3
  70. package/dist/esnext/types.d.ts +4 -3
  71. package/dist/esnext/utilities/bot-ua.js +4 -0
  72. package/dist/esnext/utilities/html-encoding.d.ts +2 -0
  73. package/dist/esnext/utilities/html-encoding.js +16 -0
  74. package/dist/esnext/utilities/image_size.d.ts +4 -22
  75. package/dist/esnext/utilities/image_size.js +15 -33
  76. package/dist/esnext/utilities/index.d.ts +2 -1
  77. package/dist/esnext/utilities/index.js +2 -1
  78. package/dist/esnext/utilities/log/log-cache-api-status.js +5 -1
  79. package/dist/esnext/version.d.ts +1 -1
  80. package/dist/esnext/version.js +1 -1
  81. package/dist/node/components/Image/Image.d.ts +84 -0
  82. package/dist/node/components/Image/Image.js +86 -0
  83. package/dist/node/components/Image/index.d.ts +2 -0
  84. package/dist/node/components/Image/index.js +5 -0
  85. package/dist/node/entry-server.d.ts +13 -1
  86. package/dist/node/entry-server.js +18 -51
  87. package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
  88. package/dist/node/framework/Hydration/Html.js +3 -1
  89. package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +1 -1
  90. package/dist/node/framework/Hydration/ServerComponentResponse.server.js +2 -1
  91. package/dist/node/framework/Hydration/rsc.d.ts +0 -3
  92. package/dist/node/framework/Hydration/rsc.js +40 -12
  93. package/dist/node/framework/cache/in-memory.js +0 -6
  94. package/dist/node/framework/cache-sub-request.d.ts +17 -0
  95. package/dist/node/framework/cache-sub-request.js +95 -0
  96. package/dist/node/framework/cache.d.ts +6 -6
  97. package/dist/node/framework/cache.js +38 -35
  98. package/dist/node/framework/plugin.js +5 -53
  99. package/dist/node/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
  100. package/dist/node/framework/plugins/vite-plugin-client-imports.js +28 -0
  101. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
  102. package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +76 -3
  103. package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
  104. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +6 -4
  105. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
  106. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +2 -3
  107. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
  108. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +41 -0
  109. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +1 -1
  110. package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +6 -3
  111. package/dist/node/storefront-api-types.d.ts +5 -3
  112. package/dist/node/storefront-api-types.js +5 -3
  113. package/dist/node/types.d.ts +4 -3
  114. package/dist/node/utilities/bot-ua.js +4 -0
  115. package/dist/node/utilities/html-encoding.d.ts +2 -0
  116. package/dist/node/utilities/html-encoding.js +21 -0
  117. package/dist/node/utilities/image_size.d.ts +4 -22
  118. package/dist/node/utilities/image_size.js +16 -58
  119. package/dist/node/utilities/index.d.ts +2 -1
  120. package/dist/node/utilities/index.js +4 -2
  121. package/dist/node/utilities/log/log-cache-api-status.js +5 -1
  122. package/dist/node/version.d.ts +1 -1
  123. package/dist/node/version.js +1 -1
  124. package/entry-server.d.ts +1 -1
  125. package/package.json +3 -3
  126. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +200 -31
  127. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +2 -0
  128. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +200 -31
  129. package/vendor/react-server-dom-vite/package.json +2 -1
  130. package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +0 -13
  131. package/dist/esnext/components/ProductDescription/ProductDescription.client.js +0 -16
  132. package/dist/esnext/components/ProductDescription/index.d.ts +0 -1
  133. package/dist/esnext/components/ProductDescription/index.js +0 -1
  134. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +0 -21
  135. package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +0 -42
  136. package/dist/esnext/components/ProductMetafield/index.d.ts +0 -2
  137. package/dist/esnext/components/ProductMetafield/index.js +0 -1
  138. package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +0 -13
  139. package/dist/esnext/components/ProductTitle/ProductTitle.client.js +0 -16
  140. package/dist/esnext/components/ProductTitle/index.d.ts +0 -1
  141. package/dist/esnext/components/ProductTitle/index.js +0 -1
  142. package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +0 -15
  143. package/dist/esnext/components/UnitPrice/UnitPrice.client.js +0 -22
  144. package/dist/esnext/components/UnitPrice/index.d.ts +0 -1
  145. package/dist/esnext/components/UnitPrice/index.js +0 -1
@@ -1,4 +1,4 @@
1
- export const CartLineAdd = `
1
+ export const CartLineAdd = (cartFragment) => `
2
2
  mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
3
3
  cartLinesAdd(cartId: $cartId, lines: $lines) {
4
4
  cart {
@@ -7,785 +7,100 @@ mutation CartLineAdd($cartId: ID!, $lines: [CartLineInput!]!, $numCartLines: Int
7
7
  }
8
8
  }
9
9
 
10
- fragment CartFragment on Cart {
11
- id
12
- checkoutUrl
13
- buyerIdentity {
14
- countryCode
15
- customer {
16
- id
17
- email
18
- firstName
19
- lastName
20
- displayName
21
- }
22
- email
23
- phone
24
- }
25
- lines(first: $numCartLines) {
26
- edges {
27
- node {
28
- id
29
- quantity
30
- attributes {
31
- key
32
- value
33
- }
34
- merchandise {
35
- ... on ProductVariant {
36
- id
37
- availableForSale
38
- compareAtPriceV2 {
39
- ...MoneyFragment
40
- }
41
- priceV2 {
42
- ...MoneyFragment
43
- }
44
- requiresShipping
45
- title
46
- image {
47
- ...ImageFragment
48
- }
49
- product {
50
- handle
51
- title
52
- }
53
- selectedOptions {
54
- name
55
- value
56
- }
57
- }
58
- }
59
- }
60
- }
61
- }
62
- estimatedCost {
63
- subtotalAmount {
64
- ...MoneyFragment
65
- }
66
- totalAmount {
67
- ...MoneyFragment
68
- }
69
- totalDutyAmount {
70
- ...MoneyFragment
71
- }
72
- totalTaxAmount {
73
- ...MoneyFragment
74
- }
75
- }
76
- note
77
- attributes {
78
- key
79
- value
80
- }
81
- discountCodes {
82
- code
83
- }
84
- }
85
-
86
- fragment MoneyFragment on MoneyV2 {
87
- currencyCode
88
- amount
89
- }
90
- fragment ImageFragment on Image {
91
- id
92
- url
93
- altText
94
- width
95
- height
96
- }
97
- `;
98
- export const CartCreate = `
99
- mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
100
- cartCreate(input: $input) {
101
- cart {
102
- ...CartFragment
103
- }
104
- }
105
- }
106
-
107
- fragment CartFragment on Cart {
108
- id
109
- checkoutUrl
110
- buyerIdentity {
111
- countryCode
112
- customer {
113
- id
114
- email
115
- firstName
116
- lastName
117
- displayName
118
- }
119
- email
120
- phone
121
- }
122
- lines(first: $numCartLines) {
123
- edges {
124
- node {
125
- id
126
- quantity
127
- attributes {
128
- key
129
- value
130
- }
131
- merchandise {
132
- ... on ProductVariant {
133
- id
134
- availableForSale
135
- compareAtPriceV2 {
136
- ...MoneyFragment
137
- }
138
- priceV2 {
139
- ...MoneyFragment
140
- }
141
- requiresShipping
142
- title
143
- image {
144
- ...ImageFragment
145
- }
146
- product {
147
- handle
148
- title
149
- }
150
- selectedOptions {
151
- name
152
- value
153
- }
154
- }
155
- }
156
- }
157
- }
158
- }
159
- estimatedCost {
160
- subtotalAmount {
161
- ...MoneyFragment
162
- }
163
- totalAmount {
164
- ...MoneyFragment
165
- }
166
- totalDutyAmount {
167
- ...MoneyFragment
168
- }
169
- totalTaxAmount {
170
- ...MoneyFragment
171
- }
172
- }
173
- note
174
- attributes {
175
- key
176
- value
177
- }
178
- discountCodes {
179
- code
180
- }
181
- }
182
-
183
- fragment MoneyFragment on MoneyV2 {
184
- currencyCode
185
- amount
186
- }
187
- fragment ImageFragment on Image {
188
- id
189
- url
190
- altText
191
- width
192
- height
193
- }
194
- `;
195
- export const CartLineRemove = `
196
- mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
197
- cartLinesRemove(cartId: $cartId, lineIds: $lines) {
198
- cart {
199
- ...CartFragment
200
- }
201
- }
202
- }
203
-
204
- fragment CartFragment on Cart {
205
- id
206
- checkoutUrl
207
- buyerIdentity {
208
- countryCode
209
- customer {
210
- id
211
- email
212
- firstName
213
- lastName
214
- displayName
215
- }
216
- email
217
- phone
218
- }
219
- lines(first: $numCartLines) {
220
- edges {
221
- node {
222
- id
223
- quantity
224
- attributes {
225
- key
226
- value
227
- }
228
- merchandise {
229
- ... on ProductVariant {
230
- id
231
- availableForSale
232
- compareAtPriceV2 {
233
- ...MoneyFragment
234
- }
235
- priceV2 {
236
- ...MoneyFragment
237
- }
238
- requiresShipping
239
- title
240
- image {
241
- ...ImageFragment
242
- }
243
- product {
244
- handle
245
- title
246
- }
247
- selectedOptions {
248
- name
249
- value
250
- }
251
- }
252
- }
253
- }
254
- }
255
- }
256
- estimatedCost {
257
- subtotalAmount {
258
- ...MoneyFragment
259
- }
260
- totalAmount {
261
- ...MoneyFragment
262
- }
263
- totalDutyAmount {
264
- ...MoneyFragment
265
- }
266
- totalTaxAmount {
267
- ...MoneyFragment
268
- }
269
- }
270
- note
271
- attributes {
272
- key
273
- value
274
- }
275
- discountCodes {
276
- code
277
- }
278
- }
279
-
280
- fragment MoneyFragment on MoneyV2 {
281
- currencyCode
282
- amount
283
- }
284
- fragment ImageFragment on Image {
285
- id
286
- url
287
- altText
288
- width
289
- height
290
- }
291
- `;
292
- export const CartLineUpdate = `
293
- mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
294
- cartLinesUpdate(cartId: $cartId, lines: $lines) {
295
- cart {
296
- ...CartFragment
297
- }
298
- }
299
- }
300
-
301
- fragment CartFragment on Cart {
302
- id
303
- checkoutUrl
304
- buyerIdentity {
305
- countryCode
306
- customer {
307
- id
308
- email
309
- firstName
310
- lastName
311
- displayName
312
- }
313
- email
314
- phone
315
- }
316
- lines(first: $numCartLines) {
317
- edges {
318
- node {
319
- id
320
- quantity
321
- attributes {
322
- key
323
- value
324
- }
325
- merchandise {
326
- ... on ProductVariant {
327
- id
328
- availableForSale
329
- compareAtPriceV2 {
330
- ...MoneyFragment
331
- }
332
- priceV2 {
333
- ...MoneyFragment
334
- }
335
- requiresShipping
336
- title
337
- image {
338
- ...ImageFragment
339
- }
340
- product {
341
- handle
342
- title
343
- }
344
- selectedOptions {
345
- name
346
- value
347
- }
348
- }
349
- }
350
- }
351
- }
352
- }
353
- estimatedCost {
354
- subtotalAmount {
355
- ...MoneyFragment
356
- }
357
- totalAmount {
358
- ...MoneyFragment
359
- }
360
- totalDutyAmount {
361
- ...MoneyFragment
362
- }
363
- totalTaxAmount {
364
- ...MoneyFragment
365
- }
366
- }
367
- note
368
- attributes {
369
- key
370
- value
371
- }
372
- discountCodes {
373
- code
374
- }
375
- }
376
-
377
- fragment MoneyFragment on MoneyV2 {
378
- currencyCode
379
- amount
380
- }
381
- fragment ImageFragment on Image {
382
- id
383
- url
384
- altText
385
- width
386
- height
387
- }
388
- `;
389
- export const CartNoteUpdate = `
390
- mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
391
- cartNoteUpdate(cartId: $cartId, note: $note) {
392
- cart {
393
- ...CartFragment
394
- }
395
- }
396
- }
397
-
398
- fragment CartFragment on Cart {
399
- id
400
- checkoutUrl
401
- buyerIdentity {
402
- countryCode
403
- customer {
404
- id
405
- email
406
- firstName
407
- lastName
408
- displayName
409
- }
410
- email
411
- phone
412
- }
413
- lines(first: $numCartLines) {
414
- edges {
415
- node {
416
- id
417
- quantity
418
- attributes {
419
- key
420
- value
421
- }
422
- merchandise {
423
- ... on ProductVariant {
424
- id
425
- availableForSale
426
- compareAtPriceV2 {
427
- ...MoneyFragment
428
- }
429
- priceV2 {
430
- ...MoneyFragment
431
- }
432
- requiresShipping
433
- title
434
- image {
435
- ...ImageFragment
436
- }
437
- product {
438
- handle
439
- title
440
- }
441
- selectedOptions {
442
- name
443
- value
444
- }
445
- }
446
- }
447
- }
448
- }
449
- }
450
- estimatedCost {
451
- subtotalAmount {
452
- ...MoneyFragment
453
- }
454
- totalAmount {
455
- ...MoneyFragment
456
- }
457
- totalDutyAmount {
458
- ...MoneyFragment
459
- }
460
- totalTaxAmount {
461
- ...MoneyFragment
462
- }
463
- }
464
- note
465
- attributes {
466
- key
467
- value
468
- }
469
- discountCodes {
470
- code
471
- }
472
- }
473
-
474
- fragment MoneyFragment on MoneyV2 {
475
- currencyCode
476
- amount
477
- }
478
- fragment ImageFragment on Image {
479
- id
480
- url
481
- altText
482
- width
483
- height
484
- }
485
- `;
486
- export const CartBuyerIdentityUpdate = `
487
- mutation CartBuyerIdentityUpdate(
488
- $cartId: ID!
489
- $buyerIdentity: CartBuyerIdentityInput!
490
- $numCartLines: Int = 250
491
- $country: CountryCode = ZZ
492
- ) @inContext(country: $country) {
493
- cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
494
- cart {
495
- ...CartFragment
496
- }
497
- }
498
- }
499
-
500
- fragment CartFragment on Cart {
501
- id
502
- checkoutUrl
503
- buyerIdentity {
504
- countryCode
505
- customer {
506
- id
507
- email
508
- firstName
509
- lastName
510
- displayName
511
- }
512
- email
513
- phone
514
- }
515
- lines(first: $numCartLines) {
516
- edges {
517
- node {
518
- id
519
- quantity
520
- attributes {
521
- key
522
- value
523
- }
524
- merchandise {
525
- ... on ProductVariant {
526
- id
527
- availableForSale
528
- compareAtPriceV2 {
529
- ...MoneyFragment
530
- }
531
- priceV2 {
532
- ...MoneyFragment
533
- }
534
- requiresShipping
535
- title
536
- image {
537
- ...ImageFragment
538
- }
539
- product {
540
- handle
541
- title
542
- }
543
- selectedOptions {
544
- name
545
- value
546
- }
547
- }
548
- }
549
- }
550
- }
551
- }
552
- estimatedCost {
553
- subtotalAmount {
554
- ...MoneyFragment
555
- }
556
- totalAmount {
557
- ...MoneyFragment
558
- }
559
- totalDutyAmount {
560
- ...MoneyFragment
561
- }
562
- totalTaxAmount {
563
- ...MoneyFragment
10
+ ${cartFragment}
11
+ `;
12
+ export const CartCreate = (cartFragment) => `
13
+ mutation CartCreate($input: CartInput!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
14
+ cartCreate(input: $input) {
15
+ cart {
16
+ ...CartFragment
564
17
  }
565
18
  }
566
- note
567
- attributes {
568
- key
569
- value
570
- }
571
- discountCodes {
572
- code
573
- }
574
19
  }
575
20
 
576
- fragment MoneyFragment on MoneyV2 {
577
- currencyCode
578
- amount
579
- }
580
- fragment ImageFragment on Image {
581
- id
582
- url
583
- altText
584
- width
585
- height
586
- }
21
+ ${cartFragment}
587
22
  `;
588
- export const CartAttributesUpdate = `
589
- mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
590
- cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
23
+ export const CartLineRemove = (cartFragment) => `
24
+ mutation CartLineRemove($cartId: ID!, $lines: [ID!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
25
+ cartLinesRemove(cartId: $cartId, lineIds: $lines) {
591
26
  cart {
592
27
  ...CartFragment
593
28
  }
594
29
  }
595
30
  }
596
31
 
597
- fragment CartFragment on Cart {
598
- id
599
- checkoutUrl
600
- buyerIdentity {
601
- countryCode
602
- customer {
603
- id
604
- email
605
- firstName
606
- lastName
607
- displayName
608
- }
609
- email
610
- phone
611
- }
612
- lines(first: $numCartLines) {
613
- edges {
614
- node {
615
- id
616
- quantity
617
- attributes {
618
- key
619
- value
620
- }
621
- merchandise {
622
- ... on ProductVariant {
623
- id
624
- availableForSale
625
- compareAtPriceV2 {
626
- ...MoneyFragment
627
- }
628
- priceV2 {
629
- ...MoneyFragment
630
- }
631
- requiresShipping
632
- title
633
- image {
634
- ...ImageFragment
635
- }
636
- product {
637
- handle
638
- title
639
- }
640
- selectedOptions {
641
- name
642
- value
643
- }
644
- }
645
- }
646
- }
647
- }
648
- }
649
- estimatedCost {
650
- subtotalAmount {
651
- ...MoneyFragment
652
- }
653
- totalAmount {
654
- ...MoneyFragment
655
- }
656
- totalDutyAmount {
657
- ...MoneyFragment
658
- }
659
- totalTaxAmount {
660
- ...MoneyFragment
32
+ ${cartFragment}
33
+ `;
34
+ export const CartLineUpdate = (cartFragment) => `
35
+ mutation CartLineUpdate($cartId: ID!, $lines: [CartLineUpdateInput!]!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
36
+ cartLinesUpdate(cartId: $cartId, lines: $lines) {
37
+ cart {
38
+ ...CartFragment
661
39
  }
662
40
  }
663
- note
664
- attributes {
665
- key
666
- value
667
- }
668
- discountCodes {
669
- code
670
- }
671
41
  }
672
42
 
673
- fragment MoneyFragment on MoneyV2 {
674
- currencyCode
675
- amount
676
- }
677
- fragment ImageFragment on Image {
678
- id
679
- url
680
- altText
681
- width
682
- height
683
- }
43
+ ${cartFragment}
684
44
  `;
685
- export const CartDiscountCodesUpdate = `
686
- mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
687
- cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
45
+ export const CartNoteUpdate = (cartFragment) => `
46
+ mutation CartNoteUpdate($cartId: ID!, $note: String, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
47
+ cartNoteUpdate(cartId: $cartId, note: $note) {
688
48
  cart {
689
49
  ...CartFragment
690
50
  }
691
51
  }
692
52
  }
693
53
 
694
- fragment CartFragment on Cart {
695
- id
696
- checkoutUrl
697
- buyerIdentity {
698
- countryCode
699
- customer {
700
- id
701
- email
702
- firstName
703
- lastName
704
- displayName
54
+ ${cartFragment}
55
+ `;
56
+ export const CartBuyerIdentityUpdate = (cartFragment) => `
57
+ mutation CartBuyerIdentityUpdate(
58
+ $cartId: ID!
59
+ $buyerIdentity: CartBuyerIdentityInput!
60
+ $numCartLines: Int = 250
61
+ $country: CountryCode = ZZ
62
+ ) @inContext(country: $country) {
63
+ cartBuyerIdentityUpdate(cartId: $cartId, buyerIdentity: $buyerIdentity) {
64
+ cart {
65
+ ...CartFragment
705
66
  }
706
- email
707
- phone
708
67
  }
709
- lines(first: $numCartLines) {
710
- edges {
711
- node {
712
- id
713
- quantity
714
- attributes {
715
- key
716
- value
717
- }
718
- merchandise {
719
- ... on ProductVariant {
720
- id
721
- availableForSale
722
- compareAtPriceV2 {
723
- ...MoneyFragment
724
- }
725
- priceV2 {
726
- ...MoneyFragment
727
- }
728
- requiresShipping
729
- title
730
- image {
731
- ...ImageFragment
732
- }
733
- product {
734
- handle
735
- title
736
- }
737
- selectedOptions {
738
- name
739
- value
740
- }
741
- }
742
- }
743
- }
68
+ }
69
+
70
+ ${cartFragment}
71
+ `;
72
+ export const CartAttributesUpdate = (cartFragment) => `
73
+ mutation CartAttributesUpdate($attributes: [AttributeInput!]!, $cartId: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
74
+ cartAttributesUpdate(attributes: $attributes, cartId: $cartId) {
75
+ cart {
76
+ ...CartFragment
744
77
  }
745
78
  }
746
- estimatedCost {
747
- subtotalAmount {
748
- ...MoneyFragment
749
- }
750
- totalAmount {
751
- ...MoneyFragment
752
- }
753
- totalDutyAmount {
754
- ...MoneyFragment
755
- }
756
- totalTaxAmount {
757
- ...MoneyFragment
79
+ }
80
+
81
+ ${cartFragment}
82
+ `;
83
+ export const CartDiscountCodesUpdate = (cartFragment) => `
84
+ mutation CartDiscountCodesUpdate($cartId: ID!, $discountCodes: [String!], $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
85
+ cartDiscountCodesUpdate(cartId: $cartId, discountCodes: $discountCodes) {
86
+ cart {
87
+ ...CartFragment
758
88
  }
759
89
  }
760
- note
761
- attributes {
762
- key
763
- value
764
- }
765
- discountCodes {
766
- code
767
- }
768
90
  }
769
91
 
770
- fragment MoneyFragment on MoneyV2 {
771
- currencyCode
772
- amount
773
- }
774
- fragment ImageFragment on Image {
775
- id
776
- url
777
- altText
778
- width
779
- height
780
- }
92
+ ${cartFragment}
781
93
  `;
782
- export const CartQuery = `
94
+ export const CartQuery = (cartFragment) => `
783
95
  query CartQuery($id: ID!, $numCartLines: Int = 250, $country: CountryCode = ZZ) @inContext(country: $country) {
784
96
  cart(id: $id) {
785
97
  ...CartFragment
786
98
  }
787
99
  }
788
100
 
101
+ ${cartFragment}
102
+ `;
103
+ export const defaultCartFragment = `
789
104
  fragment CartFragment on Cart {
790
105
  id
791
106
  checkoutUrl