You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: design-documents/graph-ql/coverage/add-items-to-cart-single-mutation.md
+22-14Lines changed: 22 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -31,12 +31,12 @@ Each product may have options. Option can be of 2 types (see example below):
31
31
]
32
32
```
33
33
34
-
We can consider "Selected Option" and "ID for Entered Option" as UUID. They meet the criteria:
34
+
We can consider "Selected Option" and "ID for Entered Option" as a globally unique identifier. They meet the criteria:
35
35
36
36
- "Selected Option" represents option value, while "ID for Entered Option" represents option
37
37
- Must be unique across different options
38
38
- Returned from server
39
-
- Used by client as is
39
+
- Used by client as is (opaque)
40
40
41
41
Selected options can be used for:
42
42
- Customizable options such as dropdwon, radiobutton, checkbox, etc
@@ -51,14 +51,22 @@ Entered options:
51
51
52
52
#### Option implementation
53
53
54
-
Product schema should be extended in order to provide option identifier (aka first iteration of "UUID").
55
-
Until introducing UUID lets name this identifier as *"id_v2"
54
+
Product schema should be extended in order to provide option identifier (aka first iteration of "UUID"). This field will be named `uid` (unique identifier, or universal ID).
56
55
57
-
Option *id_v2* is `base64` encoded string, that encodes details for each option and in most cases can be presented as
56
+
---
57
+
**Note on Field Name**
58
+
`uid` was chosen for several reasons:
59
+
-`id` is already reserved as an `Int` field in most types, and we want to avoid breaking changes
60
+
-`uuid` implies a specific encoding algorithm, and the client shouldn't know or care
61
+
-`id_v2` has a temporary-sounding name (`id_v2` makes me think `id_v3` will be coming). However, there is no need to change field names when changing the format of a field that uses the `ID` type, because clients are not meant to be parsing/formatting/inspecting `ID` values. The `uid` field can hold an integer or a base64-encoded value today, and a real UUID in the future, and it will _not_ be a breaking change.
62
+
---
63
+
64
+
65
+
For product options, for now, *uid* is a `base64` encoded string, wrapper in an `ID` type, that encodes details for each option and in most cases can be presented as
For example, for customizable drop-down option "Color(id = 1), with values Red(id = 1), Green(id = 2)" id_v2 for Color:Red will looks like `"Y3VzdG9tLW9wdGlvbi8xLzE=" => base64("custom-option/1/1")`
67
+
For example, for customizable drop-down option "Color(id = 1), with values Red(id = 1), Green(id = 2)" `uid` for Color:Red will looks like `"Y3VzdG9tLW9wdGlvbi8xLzE=" => base64("custom-option/1/1")`
60
68
61
-
Here is a GQL query that shows how to add a new field "id_v2: String!" to cover existing cases:
69
+
Here is a GQL query that shows how to add a new field "uid: ID!" to cover existing cases:
62
70
63
71
64
72
```graphql
@@ -73,15 +81,15 @@ query {
73
81
...onCustomizableRadioOption {
74
82
title
75
83
value {
76
-
id_v2 # introduce new id_v2 field in CustomizableRadioValue
84
+
uid # introduce new uid field in CustomizableRadioValue
77
85
option_type_id
78
86
title
79
87
}
80
88
}
81
89
...onCustomizableDropDownOption {
82
90
title
83
91
value {
84
-
id_v2 # introduce new id_v2 field in CustomizableDropDownValue
92
+
uid # introduce new uid field in CustomizableDropDownValue
85
93
# see \Magento\QuoteGraphQl\Model\Cart\BuyRequest\CustomizableOptionsDataProvider
86
94
option_type_id
87
95
title
@@ -92,15 +100,15 @@ query {
92
100
} ...onConfigurableProduct {
93
101
variants {
94
102
attributes {
95
-
id_v2 # introduce new id_v2 field in ConfigurableAttributeOption (format: configurable/<attribute-id>/<value_index>)
103
+
uid # introduce new uid field in ConfigurableAttributeOption (format: configurable/<attribute-id>/<value_index>)
96
104
# see \Magento\ConfigurableProductGraphQl\Model\Cart\BuyRequest\SuperAttributeDataProvider
97
105
code
98
106
value_index
99
107
}
100
108
}
101
109
} ...onDownloadableProduct {
102
110
downloadable_product_links {
103
-
id_v2 # introduce new id_v2 field in DownloadableProductLinks (format: downloadable/link/<link_id>)
111
+
uid # introduce new uid field in DownloadableProductLinks (format: downloadable/link/<link_id>)
104
112
# see \Magento\DownloadableGraphQl\Model\Cart\BuyRequest\DownloadableLinksDataProvider
105
113
title
106
114
}
@@ -109,15 +117,15 @@ query {
109
117
sku
110
118
title
111
119
options {
112
-
id_v2 # introduce new id_v2 field in BundleItemOption (format: bundle/<option-id>/<option-value-id>/<option-quantity>)
120
+
uid # introduce new uid field in BundleItemOption (format: bundle/<option-id>/<option-value-id>/<option-quantity>)
113
121
# see \Magento\BundleGraphQl\Model\Cart\BuyRequest\BundleDataProvider
114
122
id
115
123
label
116
124
}
117
125
}
118
126
} ...onGiftCardProduct {
119
127
giftcard_amounts {
120
-
id_v2 # introduce new id_v2 field in GiftCardAmounts (format: giftcard/...TBD)
128
+
uid # introduce new uid field in GiftCardAmounts (format: giftcard/...TBD)
121
129
# see \Magento\GiftCard\Model\Quote\Item\CartItemProcessor::convertToBuyRequest
122
130
value_id
123
131
website_id
@@ -154,7 +162,7 @@ query {
154
162
155
163
In this example we want to add _personalized blue cup to cart_ to cart.
156
164
157
-
-`selected_options` - predefined and selected by customer options. `base64` encoding will help to use UUID in future.
165
+
-`selected_options` - predefined and selected by customer options. `base64` encoding is temporary until Magento supports UUIDs, but this is unknown to the client and purely a server implementation detail.
158
166
:warning: The encoded value will be returned from server and should be used by client as is.
0 commit comments