@cobrastyle/adapter-magento2 1.0.1

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.
@@ -0,0 +1,1193 @@
1
+ // Product Queries
2
+ export const GET_PRODUCT_BY_URL_KEY = `
3
+ query GetProductByUrlKey($urlKey: String!) {
4
+ products(filter: { url_key: { eq: $urlKey } }) {
5
+ items {
6
+ __typename
7
+ id
8
+ sku
9
+ name
10
+ url_key
11
+ description { html }
12
+ short_description { html }
13
+ meta_title
14
+ meta_description
15
+ stock_status
16
+ price_range {
17
+ minimum_price {
18
+ regular_price { value currency }
19
+ final_price { value currency }
20
+ discount { amount_off percent_off }
21
+ }
22
+ }
23
+ price_tiers {
24
+ quantity
25
+ final_price { value currency }
26
+ discount { amount_off percent_off }
27
+ }
28
+ media_gallery {
29
+ url
30
+ label
31
+ position
32
+ }
33
+ categories {
34
+ id
35
+ name
36
+ url_key
37
+ breadcrumbs {
38
+ category_url_key
39
+ category_level
40
+ }
41
+ }
42
+ custom_attributesV2(filters: { is_visible_on_front: true }) {
43
+ items {
44
+ code
45
+ __typename
46
+ ... on AttributeValue {
47
+ value
48
+ }
49
+ ... on AttributeSelectedOptions {
50
+ selected_options {
51
+ label
52
+ value
53
+ }
54
+ }
55
+ }
56
+ errors {
57
+ message
58
+ }
59
+ }
60
+ ... on ConfigurableProduct {
61
+ configurable_options {
62
+ id
63
+ attribute_code
64
+ label
65
+ values {
66
+ uid
67
+ label
68
+ swatch_data {
69
+ __typename
70
+ value
71
+ }
72
+ }
73
+ }
74
+ variants {
75
+ product {
76
+ id
77
+ sku
78
+ name
79
+ stock_status
80
+ price_range {
81
+ minimum_price {
82
+ regular_price { value currency }
83
+ final_price { value currency }
84
+ }
85
+ }
86
+ }
87
+ attributes {
88
+ code
89
+ label
90
+ value_index
91
+ }
92
+ }
93
+ }
94
+ ... on GroupedProduct {
95
+ items {
96
+ qty
97
+ position
98
+ product {
99
+ ... on ProductInterface {
100
+ __typename
101
+ id
102
+ uid
103
+ sku
104
+ name
105
+ url_key
106
+ stock_status
107
+ price_range {
108
+ minimum_price {
109
+ regular_price { value currency }
110
+ final_price { value currency }
111
+ discount { amount_off percent_off }
112
+ }
113
+ }
114
+ thumbnail { url label }
115
+ }
116
+ }
117
+ }
118
+ }
119
+ }
120
+ }
121
+ }
122
+ `;
123
+ export const GET_PRODUCT_BY_ID = `
124
+ query GetProductBySku($sku: String!) {
125
+ products(filter: { sku: { eq: $sku } }) {
126
+ items {
127
+ id
128
+ sku
129
+ name
130
+ url_key
131
+ description { html }
132
+ short_description { html }
133
+ meta_title
134
+ meta_description
135
+ stock_status
136
+ price_range {
137
+ minimum_price {
138
+ regular_price { value currency }
139
+ final_price { value currency }
140
+ discount { amount_off percent_off }
141
+ }
142
+ }
143
+ price_tiers {
144
+ quantity
145
+ final_price { value currency }
146
+ discount { amount_off percent_off }
147
+ }
148
+ media_gallery {
149
+ url
150
+ label
151
+ position
152
+ }
153
+ categories {
154
+ id
155
+ name
156
+ url_key
157
+ breadcrumbs {
158
+ category_url_key
159
+ category_level
160
+ }
161
+ }
162
+ custom_attributesV2(filters: { is_visible_on_front: true }) {
163
+ items {
164
+ code
165
+ __typename
166
+ ... on AttributeValue {
167
+ value
168
+ }
169
+ ... on AttributeSelectedOptions {
170
+ selected_options {
171
+ label
172
+ value
173
+ }
174
+ }
175
+ }
176
+ errors {
177
+ message
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ `;
184
+ // `custom_attributesV2` items carry only the attribute `code`, not its
185
+ // storefront label, so we fetch the code→label map once per store and join it
186
+ // in when mapping products. `is_visible_on_front` mirrors what Magento's own
187
+ // "More Information" tab shows.
188
+ export const GET_PRODUCT_ATTRIBUTE_LABELS = `
189
+ query GetProductAttributeLabels {
190
+ attributesList(entityType: CATALOG_PRODUCT, filters: { is_visible_on_front: true }) {
191
+ items {
192
+ code
193
+ label
194
+ }
195
+ errors {
196
+ message
197
+ }
198
+ }
199
+ }
200
+ `;
201
+ // Category Queries
202
+ export const GET_CATEGORY_BY_URL_KEY = `
203
+ query GetCategoryByUrlKey($urlKey: String!) {
204
+ categoryList(filters: { url_path: { eq: $urlKey } }) {
205
+ id
206
+ uid
207
+ name
208
+ url_key
209
+ url_path
210
+ description
211
+ image
212
+ meta_title
213
+ meta_description
214
+ product_count
215
+ breadcrumbs {
216
+ category_id
217
+ category_uid
218
+ category_name
219
+ category_url_key
220
+ category_url_path
221
+ category_level
222
+ }
223
+ children {
224
+ id
225
+ uid
226
+ name
227
+ url_key
228
+ url_path
229
+ product_count
230
+ }
231
+ }
232
+ }
233
+ `;
234
+ // Fallback query using url_key (single segment)
235
+ export const GET_CATEGORY_BY_URL_KEY_SINGLE = `
236
+ query GetCategoryByUrlKeySingle($urlKey: String!) {
237
+ categoryList(filters: { url_key: { eq: $urlKey } }) {
238
+ id
239
+ uid
240
+ name
241
+ url_key
242
+ url_path
243
+ description
244
+ image
245
+ meta_title
246
+ meta_description
247
+ product_count
248
+ breadcrumbs {
249
+ category_id
250
+ category_uid
251
+ category_name
252
+ category_url_key
253
+ category_url_path
254
+ category_level
255
+ }
256
+ children {
257
+ id
258
+ uid
259
+ name
260
+ url_key
261
+ url_path
262
+ product_count
263
+ }
264
+ }
265
+ }
266
+ `;
267
+ // Lookup by uid — unambiguous, used by URL resolution (immune to stale
268
+ // url_path and to duplicate url_keys across the category tree).
269
+ export const GET_CATEGORY_BY_UID = `
270
+ query GetCategoryByUid($uid: String!) {
271
+ categoryList(filters: { category_uid: { eq: $uid } }) {
272
+ id
273
+ uid
274
+ name
275
+ url_key
276
+ url_path
277
+ description
278
+ image
279
+ meta_title
280
+ meta_description
281
+ product_count
282
+ breadcrumbs {
283
+ category_id
284
+ category_uid
285
+ category_name
286
+ category_url_key
287
+ category_url_path
288
+ category_level
289
+ }
290
+ children {
291
+ id
292
+ uid
293
+ name
294
+ url_key
295
+ url_path
296
+ product_count
297
+ }
298
+ }
299
+ }
300
+ `;
301
+ // Category name matches for search autocomplete suggestions.
302
+ export const GET_CATEGORY_SUGGESTIONS = `
303
+ query GetCategorySuggestions($name: String!) {
304
+ categoryList(filters: { name: { match: $name } }) {
305
+ uid
306
+ name
307
+ url_key
308
+ url_path
309
+ }
310
+ }
311
+ `;
312
+ export const GET_CATEGORY_PRODUCTS = `
313
+ query GetCategoryProducts(
314
+ $pageSize: Int!
315
+ $currentPage: Int!
316
+ $filter: ProductAttributeFilterInput!
317
+ $sort: ProductAttributeSortInput
318
+ ) {
319
+ products(
320
+ filter: $filter
321
+ pageSize: $pageSize
322
+ currentPage: $currentPage
323
+ sort: $sort
324
+ ) {
325
+ total_count
326
+ page_info {
327
+ current_page
328
+ page_size
329
+ total_pages
330
+ }
331
+ items {
332
+ id
333
+ sku
334
+ name
335
+ url_key
336
+ stock_status
337
+ price_range {
338
+ minimum_price {
339
+ regular_price { value currency }
340
+ final_price { value currency }
341
+ discount { amount_off percent_off }
342
+ }
343
+ }
344
+ price_tiers {
345
+ quantity
346
+ final_price { value currency }
347
+ discount { amount_off percent_off }
348
+ }
349
+ thumbnail {
350
+ url
351
+ label
352
+ }
353
+ }
354
+ aggregations(filter: { category: { includeDirectChildrenOnly: false } }) {
355
+ attribute_code
356
+ label
357
+ options {
358
+ value
359
+ label
360
+ count
361
+ }
362
+ }
363
+ sort_fields {
364
+ default
365
+ options {
366
+ value
367
+ label
368
+ }
369
+ }
370
+ }
371
+ }
372
+ `;
373
+ // Store Config Query
374
+ export const GET_STORE_CONFIG = `
375
+ query GetStoreConfig {
376
+ storeConfig {
377
+ root_category_uid
378
+ root_category_id
379
+ store_code
380
+ store_name
381
+ base_currency_code
382
+ default_display_currency_code
383
+ locale
384
+ timezone
385
+ category_url_suffix
386
+ product_url_suffix
387
+ use_store_in_url
388
+ cms_home_page
389
+ cms_no_route
390
+ default_title
391
+ default_description
392
+ default_keywords
393
+ title_prefix
394
+ title_suffix
395
+ title_separator
396
+ }
397
+ }
398
+ `;
399
+ // All store views (locale + currency + code), for the store registry.
400
+ export const GET_AVAILABLE_STORES = `
401
+ query GetAvailableStores {
402
+ availableStores(useCurrentGroup: false) {
403
+ store_code
404
+ store_name
405
+ locale
406
+ base_currency_code
407
+ default_display_currency_code
408
+ is_default_store
409
+ base_url
410
+ }
411
+ }
412
+ `;
413
+ // Countries + their available regions, for checkout country/region pickers.
414
+ export const GET_COUNTRIES = `
415
+ query GetCountries {
416
+ countries {
417
+ two_letter_abbreviation
418
+ full_name_locale
419
+ available_regions {
420
+ id
421
+ code
422
+ name
423
+ }
424
+ }
425
+ }
426
+ `;
427
+ export const GET_NAVIGATION = `
428
+ query GetNavigation($id: Int!) {
429
+ category(id: $id) {
430
+ id
431
+ children {
432
+ id
433
+ name
434
+ url_key
435
+ url_path
436
+ position
437
+ level
438
+ include_in_menu
439
+ children {
440
+ id
441
+ name
442
+ url_key
443
+ url_path
444
+ position
445
+ level
446
+ include_in_menu
447
+ children {
448
+ id
449
+ name
450
+ url_key
451
+ url_path
452
+ position
453
+ level
454
+ include_in_menu
455
+ }
456
+ }
457
+ }
458
+ }
459
+ }
460
+ `;
461
+ // Cart Queries
462
+ export const CREATE_EMPTY_CART = `
463
+ mutation CreateEmptyCart {
464
+ createEmptyCart
465
+ }
466
+ `;
467
+ export const GET_CART = `
468
+ query GetCart($cartId: String!) {
469
+ cart(cart_id: $cartId) {
470
+ id
471
+ email
472
+ items {
473
+ uid
474
+ product {
475
+ id
476
+ sku
477
+ name
478
+ url_key
479
+ thumbnail { url label }
480
+ }
481
+ quantity
482
+ prices {
483
+ price { value currency }
484
+ row_total { value currency }
485
+ row_total_including_tax { value currency }
486
+ }
487
+ ... on ConfigurableCartItem {
488
+ configurable_options {
489
+ option_label
490
+ value_label
491
+ }
492
+ }
493
+ }
494
+ prices {
495
+ subtotal_excluding_tax { value currency }
496
+ subtotal_including_tax { value currency }
497
+ grand_total { value currency }
498
+ discounts {
499
+ amount { value currency }
500
+ label
501
+ }
502
+ applied_taxes {
503
+ amount { value currency }
504
+ label
505
+ }
506
+ }
507
+ applied_coupons {
508
+ code
509
+ }
510
+ shipping_addresses {
511
+ firstname
512
+ lastname
513
+ street
514
+ city
515
+ region { code label }
516
+ postcode
517
+ country { code label }
518
+ telephone
519
+ available_shipping_methods {
520
+ carrier_code
521
+ carrier_title
522
+ method_code
523
+ method_title
524
+ amount { value currency }
525
+ }
526
+ selected_shipping_method {
527
+ carrier_code
528
+ carrier_title
529
+ method_code
530
+ method_title
531
+ amount { value currency }
532
+ }
533
+ }
534
+ billing_address {
535
+ firstname
536
+ lastname
537
+ street
538
+ city
539
+ region { code label }
540
+ postcode
541
+ country { code label }
542
+ telephone
543
+ }
544
+ available_payment_methods {
545
+ code
546
+ title
547
+ }
548
+ selected_payment_method {
549
+ code
550
+ title
551
+ }
552
+ }
553
+ }
554
+ `;
555
+ export const ADD_TO_CART = `
556
+ mutation AddToCart($cartId: String!, $cartItems: [CartItemInput!]!) {
557
+ addProductsToCart(
558
+ cartId: $cartId
559
+ cartItems: $cartItems
560
+ ) {
561
+ cart {
562
+ id
563
+ items {
564
+ uid
565
+ product { id sku name url_key thumbnail { url label } }
566
+ quantity
567
+ prices {
568
+ price { value currency }
569
+ row_total { value currency }
570
+ row_total_including_tax { value currency }
571
+ }
572
+ ... on ConfigurableCartItem {
573
+ configurable_options {
574
+ option_label
575
+ value_label
576
+ }
577
+ }
578
+ }
579
+ prices {
580
+ subtotal_excluding_tax { value currency }
581
+ subtotal_including_tax { value currency }
582
+ grand_total { value currency }
583
+ }
584
+ }
585
+ user_errors {
586
+ code
587
+ message
588
+ }
589
+ }
590
+ }
591
+ `;
592
+ export const UPDATE_CART_ITEM = `
593
+ mutation UpdateCartItem($cartId: String!, $itemUid: ID!, $quantity: Float!) {
594
+ updateCartItems(
595
+ input: {
596
+ cart_id: $cartId
597
+ cart_items: [{ cart_item_uid: $itemUid, quantity: $quantity }]
598
+ }
599
+ ) {
600
+ cart {
601
+ id
602
+ items {
603
+ uid
604
+ product { id sku name url_key thumbnail { url label } }
605
+ quantity
606
+ prices {
607
+ price { value currency }
608
+ row_total { value currency }
609
+ row_total_including_tax { value currency }
610
+ }
611
+ }
612
+ prices {
613
+ subtotal_excluding_tax { value currency }
614
+ subtotal_including_tax { value currency }
615
+ grand_total { value currency }
616
+ }
617
+ }
618
+ }
619
+ }
620
+ `;
621
+ export const REMOVE_CART_ITEM = `
622
+ mutation RemoveCartItem($cartId: String!, $itemUid: ID!) {
623
+ removeItemFromCart(input: { cart_id: $cartId, cart_item_uid: $itemUid }) {
624
+ cart {
625
+ id
626
+ items {
627
+ uid
628
+ product { id sku name url_key thumbnail { url label } }
629
+ quantity
630
+ prices {
631
+ price { value currency }
632
+ row_total { value currency }
633
+ row_total_including_tax { value currency }
634
+ }
635
+ }
636
+ prices {
637
+ subtotal_excluding_tax { value currency }
638
+ subtotal_including_tax { value currency }
639
+ grand_total { value currency }
640
+ }
641
+ }
642
+ }
643
+ }
644
+ `;
645
+ // URL Resolver
646
+ export const URL_RESOLVER = `
647
+ query UrlResolver($url: String!) {
648
+ route(url: $url) {
649
+ __typename
650
+ ... on ProductInterface {
651
+ id
652
+ uid
653
+ sku
654
+ url_key
655
+ }
656
+ ... on CategoryTree {
657
+ id
658
+ uid
659
+ url_key
660
+ }
661
+ ... on CmsPage {
662
+ identifier
663
+ url_key
664
+ }
665
+ }
666
+ }
667
+ `;
668
+ // CMS Queries
669
+ export const GET_CMS_PAGE = `
670
+ query GetCmsPage($identifier: String!) {
671
+ cmsPage(identifier: $identifier) {
672
+ identifier
673
+ url_key
674
+ title
675
+ content
676
+ content_heading
677
+ meta_title
678
+ meta_description
679
+ }
680
+ }
681
+ `;
682
+ export const GET_CMS_BLOCKS = `
683
+ query GetCmsBlocks($identifiers: [String!]!) {
684
+ cmsBlocks(identifiers: $identifiers) {
685
+ items {
686
+ identifier
687
+ title
688
+ content
689
+ }
690
+ }
691
+ }
692
+ `;
693
+ // Search Query
694
+ export const SEARCH_PRODUCTS = `
695
+ query SearchProducts($search: String!, $pageSize: Int!, $currentPage: Int!) {
696
+ products(search: $search, pageSize: $pageSize, currentPage: $currentPage) {
697
+ total_count
698
+ page_info {
699
+ current_page
700
+ page_size
701
+ total_pages
702
+ }
703
+ items {
704
+ id
705
+ sku
706
+ name
707
+ url_key
708
+ stock_status
709
+ price_range {
710
+ minimum_price {
711
+ regular_price { value currency }
712
+ final_price { value currency }
713
+ discount { amount_off percent_off }
714
+ }
715
+ }
716
+ price_tiers {
717
+ quantity
718
+ final_price { value currency }
719
+ discount { amount_off percent_off }
720
+ }
721
+ thumbnail {
722
+ url
723
+ label
724
+ }
725
+ }
726
+ }
727
+ }
728
+ `;
729
+ // Customer Queries
730
+ export const GENERATE_CUSTOMER_TOKEN = `
731
+ mutation GenerateCustomerToken($email: String!, $password: String!) {
732
+ generateCustomerToken(email: $email, password: $password) {
733
+ token
734
+ }
735
+ }
736
+ `;
737
+ export const CREATE_CUSTOMER = `
738
+ mutation CreateCustomer($input: CustomerCreateInput!) {
739
+ createCustomerV2(input: $input) {
740
+ customer {
741
+ id
742
+ email
743
+ firstname
744
+ lastname
745
+ date_of_birth
746
+ gender
747
+ created_at
748
+ }
749
+ }
750
+ }
751
+ `;
752
+ export const GET_CUSTOMER = `
753
+ query GetCustomer {
754
+ customer {
755
+ id
756
+ email
757
+ firstname
758
+ lastname
759
+ date_of_birth
760
+ gender
761
+ created_at
762
+ addresses {
763
+ id
764
+ firstname
765
+ lastname
766
+ street
767
+ city
768
+ region { region_code region region_id }
769
+ postcode
770
+ country_code
771
+ telephone
772
+ company
773
+ default_shipping
774
+ default_billing
775
+ }
776
+ }
777
+ }
778
+ `;
779
+ // Address CRUD Mutations
780
+ const ADDRESS_FIELDS = `
781
+ id
782
+ firstname
783
+ lastname
784
+ street
785
+ city
786
+ region { region_code region region_id }
787
+ postcode
788
+ country_code
789
+ telephone
790
+ company
791
+ default_shipping
792
+ default_billing
793
+ `;
794
+ export const CREATE_CUSTOMER_ADDRESS = `
795
+ mutation CreateCustomerAddress($input: CustomerAddressInput!) {
796
+ createCustomerAddress(input: $input) {
797
+ ${ADDRESS_FIELDS}
798
+ }
799
+ }
800
+ `;
801
+ export const UPDATE_CUSTOMER_ADDRESS = `
802
+ mutation UpdateCustomerAddress($id: Int!, $input: CustomerAddressInput!) {
803
+ updateCustomerAddress(id: $id, input: $input) {
804
+ ${ADDRESS_FIELDS}
805
+ }
806
+ }
807
+ `;
808
+ export const DELETE_CUSTOMER_ADDRESS = `
809
+ mutation DeleteCustomerAddress($id: Int!) {
810
+ deleteCustomerAddress(id: $id)
811
+ }
812
+ `;
813
+ export const GET_CUSTOMER_ORDERS = `
814
+ query GetCustomerOrders($pageSize: Int!, $currentPage: Int!) {
815
+ customer {
816
+ orders(pageSize: $pageSize, currentPage: $currentPage) {
817
+ total_count
818
+ page_info {
819
+ current_page
820
+ page_size
821
+ total_pages
822
+ }
823
+ items {
824
+ id
825
+ number
826
+ order_date
827
+ status
828
+ total {
829
+ grand_total { value currency }
830
+ subtotal_excl_tax { value currency }
831
+ total_shipping { value currency }
832
+ total_tax { value currency }
833
+ discounts { amount { value currency } label }
834
+ }
835
+ shipping_address {
836
+ firstname
837
+ lastname
838
+ street
839
+ city
840
+ region
841
+ postcode
842
+ country_code
843
+ telephone
844
+ }
845
+ items {
846
+ id
847
+ product_name
848
+ product_sku
849
+ quantity_ordered
850
+ product_sale_price {
851
+ value
852
+ currency
853
+ }
854
+ product_url_key
855
+ }
856
+ }
857
+ }
858
+ }
859
+ }
860
+ `;
861
+ // Checkout Mutations
862
+ export const SET_SHIPPING_ADDRESS = `
863
+ mutation SetShippingAddress($cartId: String!, $address: ShippingAddressInput!) {
864
+ setShippingAddressesOnCart(
865
+ input: { cart_id: $cartId, shipping_addresses: [$address] }
866
+ ) {
867
+ cart {
868
+ id
869
+ shipping_addresses {
870
+ firstname
871
+ lastname
872
+ street
873
+ city
874
+ region { code label }
875
+ postcode
876
+ country { code label }
877
+ telephone
878
+ available_shipping_methods {
879
+ carrier_code
880
+ carrier_title
881
+ method_code
882
+ method_title
883
+ amount { value currency }
884
+ }
885
+ }
886
+ }
887
+ }
888
+ }
889
+ `;
890
+ export const SET_SHIPPING_METHOD = `
891
+ mutation SetShippingMethod(
892
+ $cartId: String!
893
+ $carrierCode: String!
894
+ $methodCode: String!
895
+ ) {
896
+ setShippingMethodsOnCart(
897
+ input: {
898
+ cart_id: $cartId
899
+ shipping_methods: [
900
+ { carrier_code: $carrierCode, method_code: $methodCode }
901
+ ]
902
+ }
903
+ ) {
904
+ cart {
905
+ id
906
+ shipping_addresses {
907
+ selected_shipping_method {
908
+ carrier_code
909
+ carrier_title
910
+ method_code
911
+ method_title
912
+ amount { value currency }
913
+ }
914
+ }
915
+ prices {
916
+ grand_total { value currency }
917
+ }
918
+ }
919
+ }
920
+ }
921
+ `;
922
+ export const SET_PAYMENT_METHOD = `
923
+ mutation SetPaymentMethod($cartId: String!, $code: String!) {
924
+ setPaymentMethodOnCart(
925
+ input: { cart_id: $cartId, payment_method: { code: $code } }
926
+ ) {
927
+ cart {
928
+ id
929
+ selected_payment_method {
930
+ code
931
+ title
932
+ }
933
+ }
934
+ }
935
+ }
936
+ `;
937
+ export const PLACE_ORDER = `
938
+ mutation PlaceOrder($cartId: String!) {
939
+ placeOrder(input: { cart_id: $cartId }) {
940
+ order {
941
+ order_number
942
+ }
943
+ }
944
+ }
945
+ `;
946
+ // Related Products Query
947
+ export const GET_RELATED_PRODUCTS = `
948
+ query GetRelatedProducts($urlKey: String!) {
949
+ products(filter: { url_key: { eq: $urlKey } }) {
950
+ items {
951
+ related_products {
952
+ __typename
953
+ id
954
+ uid
955
+ sku
956
+ name
957
+ url_key
958
+ stock_status
959
+ price_range {
960
+ minimum_price {
961
+ regular_price { value currency }
962
+ final_price { value currency }
963
+ discount { amount_off percent_off }
964
+ }
965
+ }
966
+ thumbnail {
967
+ url
968
+ label
969
+ }
970
+ }
971
+ upsell_products {
972
+ __typename
973
+ id
974
+ uid
975
+ sku
976
+ name
977
+ url_key
978
+ stock_status
979
+ price_range {
980
+ minimum_price {
981
+ regular_price { value currency }
982
+ final_price { value currency }
983
+ discount { amount_off percent_off }
984
+ }
985
+ }
986
+ thumbnail {
987
+ url
988
+ label
989
+ }
990
+ }
991
+ }
992
+ }
993
+ }
994
+ `;
995
+ // Related Products Query by SKU
996
+ export const GET_RELATED_PRODUCTS_BY_SKU = `
997
+ query GetRelatedProductsBySku($sku: String!) {
998
+ products(filter: { sku: { eq: $sku } }) {
999
+ items {
1000
+ related_products {
1001
+ __typename
1002
+ id
1003
+ uid
1004
+ sku
1005
+ name
1006
+ url_key
1007
+ stock_status
1008
+ price_range {
1009
+ minimum_price {
1010
+ regular_price { value currency }
1011
+ final_price { value currency }
1012
+ discount { amount_off percent_off }
1013
+ }
1014
+ }
1015
+ thumbnail {
1016
+ url
1017
+ label
1018
+ }
1019
+ }
1020
+ upsell_products {
1021
+ __typename
1022
+ id
1023
+ uid
1024
+ sku
1025
+ name
1026
+ url_key
1027
+ stock_status
1028
+ price_range {
1029
+ minimum_price {
1030
+ regular_price { value currency }
1031
+ final_price { value currency }
1032
+ discount { amount_off percent_off }
1033
+ }
1034
+ }
1035
+ thumbnail {
1036
+ url
1037
+ label
1038
+ }
1039
+ }
1040
+ }
1041
+ }
1042
+ }
1043
+ `;
1044
+ export const GET_PRODUCTS_BY_SKUS = `
1045
+ query GetProductsBySkus($skus: [String!]!, $pageSize: Int!) {
1046
+ products(filter: { sku: { in: $skus } }, pageSize: $pageSize) {
1047
+ items {
1048
+ id
1049
+ sku
1050
+ name
1051
+ url_key
1052
+ stock_status
1053
+ price_range {
1054
+ minimum_price {
1055
+ regular_price { value currency }
1056
+ final_price { value currency }
1057
+ discount { amount_off percent_off }
1058
+ }
1059
+ }
1060
+ price_tiers {
1061
+ quantity
1062
+ final_price { value currency }
1063
+ discount { amount_off percent_off }
1064
+ }
1065
+ thumbnail { url label }
1066
+ }
1067
+ }
1068
+ }
1069
+ `;
1070
+ // Customer Cart Queries
1071
+ export const GET_CUSTOMER_CART = `
1072
+ query GetCustomerCart {
1073
+ customerCart {
1074
+ id
1075
+ }
1076
+ }
1077
+ `;
1078
+ export const MERGE_CARTS = `
1079
+ mutation MergeCarts($guestCartId: String!, $customerCartId: String!) {
1080
+ mergeCarts(source_cart_id: $guestCartId, destination_cart_id: $customerCartId) {
1081
+ id
1082
+ }
1083
+ }
1084
+ `;
1085
+ // Wishlist Queries
1086
+ // Using 'wishlists' (plural) which returns all customer wishlists without requiring an ID
1087
+ export const GET_CUSTOMER_WISHLIST = `
1088
+ query GetCustomerWishlist {
1089
+ customer {
1090
+ wishlists {
1091
+ id
1092
+ items_count
1093
+ items_v2 {
1094
+ items {
1095
+ id
1096
+ added_at
1097
+ product {
1098
+ sku
1099
+ name
1100
+ url_key
1101
+ stock_status
1102
+ price_range {
1103
+ minimum_price {
1104
+ regular_price { value currency }
1105
+ final_price { value currency }
1106
+ discount { amount_off percent_off }
1107
+ }
1108
+ }
1109
+ thumbnail {
1110
+ url
1111
+ label
1112
+ }
1113
+ }
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
+ `;
1120
+ export const ADD_TO_WISHLIST = `
1121
+ mutation AddToWishlist($wishlistId: ID!, $items: [WishlistItemInput!]!) {
1122
+ addProductsToWishlist(wishlistId: $wishlistId, wishlistItems: $items) {
1123
+ wishlist {
1124
+ id
1125
+ items_count
1126
+ items_v2 {
1127
+ items {
1128
+ id
1129
+ added_at
1130
+ product {
1131
+ sku
1132
+ name
1133
+ url_key
1134
+ stock_status
1135
+ price_range {
1136
+ minimum_price {
1137
+ regular_price { value currency }
1138
+ final_price { value currency }
1139
+ discount { amount_off percent_off }
1140
+ }
1141
+ }
1142
+ thumbnail {
1143
+ url
1144
+ label
1145
+ }
1146
+ }
1147
+ }
1148
+ }
1149
+ }
1150
+ user_errors {
1151
+ code
1152
+ message
1153
+ }
1154
+ }
1155
+ }
1156
+ `;
1157
+ export const REMOVE_FROM_WISHLIST = `
1158
+ mutation RemoveFromWishlist($wishlistId: ID!, $itemIds: [ID!]!) {
1159
+ removeProductsFromWishlist(wishlistId: $wishlistId, wishlistItemsIds: $itemIds) {
1160
+ wishlist {
1161
+ id
1162
+ items_count
1163
+ items_v2 {
1164
+ items {
1165
+ id
1166
+ added_at
1167
+ product {
1168
+ sku
1169
+ name
1170
+ url_key
1171
+ stock_status
1172
+ price_range {
1173
+ minimum_price {
1174
+ regular_price { value currency }
1175
+ final_price { value currency }
1176
+ discount { amount_off percent_off }
1177
+ }
1178
+ }
1179
+ thumbnail {
1180
+ url
1181
+ label
1182
+ }
1183
+ }
1184
+ }
1185
+ }
1186
+ }
1187
+ user_errors {
1188
+ code
1189
+ message
1190
+ }
1191
+ }
1192
+ }
1193
+ `;