How to use selected_options and entered_options in GraphQL Query Magento 2?

What is the Difference between selected_options vs entered_options GraphQL?
From the Magento version 2.4, You can see new architectural changes for the Data Transfer Object(DTO) will be used widely in GraphQL Query.

You have also marked new updates selected_options and entered_options in the GraphQL Query.

selected and entered options value must be base64_encode in the query and you can use this feature in add to cart and wishlist by GraphQL mutation.

There will be two types of Options for each type of option in Magento.

  • selected_options: Selected Options will be used when you can select already existing options from the product or custom options. Its predefined options are available with the product.

Example, Drop Down, Radio Button, Checkbox, Swatch Attribute

For Example, Configurable product with choose color or size, Bundle with choose a different combination of items by click on the radio or checkbox.
All those options that will be selected from the product will be used as selected options.

A configurable item with two attributes, color, and size,

Each Option base64 will be in a new line for the selected_options/entered options.

  • entered_options: An option entered by customers like text field, text area, date, image, etc. All those options where user manual input will be needed to be used as entered options.

For example, Product with a custom option type field and image, you need to enter an input value to a specific field.

Different types of Items syntax to create base64 encoded value,

1. Configurable Item syntax,

Color Attribute Id 93 and Option Value Red Id 67

2. Bundle Item syntax,

<OPTION_TYPE> will be a bundle
<OPTION_ID> will be option id
<OPTION_VALUE_ID> will be option value id
<OPTION_QUANTITY> will be option qty

selected options for bundle item with child selection,


3. Downloadable Item syntax

<OPTION_TYPE> will be downloadable
<OPTION_LINK_Id> will be Item Link id.

For example,
Downloadable product SKU 240-LV09 from the Magento sample data,
Downloadable Episode 1 option id will be 6.
base64_encode("downloadable/6") // ZG93bmxvYWRhYmxlLzY=

4. Custom Options Item Syntax,

Example, for Custom drop-down option for the Custom option Product,
“Gender(id = 1), with values Male(id = 1), Female(id = 2)”

OPTION_TYPE equals custom-option
OPTION_ID equals Gender(id = 1)
OPTION_VALUE_ID equals female(id = 2)

uid for Gender with Female will looks like,