How to update option values

In this example you will learn how to update the option values for an existing advert or variant.

What you’ll learn

  • Recap of option types and associated terminology
  • The 2 methods of updating option values
  • Focused examples on partially updating option values

Terminology Recap

In discussing how we can update the Option Values of a Product (Advert) and its Variants, it’s worth reviewing some core concepts. The diagram below depicts these:

NOTE: For brevity we have only depicted a subset of possible Option Values


Advert Schema


TermAliasDescription
Option TypeAttributeOption Types refer to the way an Advert or Variant can be defined. So common Option Types would be color and Size. Option Types will then have 1 or move Option Values, which contain the range of values that it is possible for the Option Type to have.
Option ValueAttribute ValueThe values that an Option Type can have. In the example where we have an Option Type of Color, possible Option Values would be: Red, Green, Blue etc.
PrototypeAttribute GroupPrototypes are the glue between a Taxon and the Option Types that Taxon has. So we assign Option Types to a Prototype, and then assign a Prototype to the Taxon. This means we can assign that same defined Prototype to any number of other Taxons.
TaxonCategoryA taxon represents where the product sits in the categorization hierarchy. The products taxon, determines the Option Values that can be assigned to it, this relationship is enabled via the prototype.

Option Types

Option Types in Marketplacer can be of 1 of 3 types:

  • Single Select
  • Multi Select
  • Free text

These option types can be applied at either the Product (Advert) or Variant level, and can be specified as optional.

For further detail on these concepts, as well as how to create adverts, please refer to this article.

Methods of updating Option Values

You can use 1 of 2 approaches to update the existing Option Values of an Advert or Variant:

Method 1 - Provide all required values

With this approach if you had an Advert with the following Option Values:

  • Cellular Material (Single Select)
    • Plastic
  • Cellular Network (Multi Select)
    • 3G
    • 4G

If you wanted to update this Advert to additionally include “5G” value for Cellular Network, you would provide the following values to your mutation call:

  • Cellular Material (Single Select)
    • Plastic
  • Cellular Network (Multi Select)
    • 3G
    • 4G
    • 5G

In short, you’d need to re-supply all values, including the existing ones. Any existing values that you did not supply (e.g. “Plastic”) would be removed.

Method 2 - Provide only delta changes

With this approach if you had an Advert with the following Option Values:

  • Cellular Material (Single Select)
    • Plastic
  • Cellular Network (Multi Select)
    • 3G
    • 4G

If you wanted to update this Advert to set the Cellular Material to “Aluminium”, you would only need to provide the following to your mutation call:

  • Cellular Material (Single Select)
    • Aluminium

All existing values remain in-place.

It should be noted that even if you are using Method 2, when you are updating multi select option values, you need to supply all the multi-select values you require. For example, using the same scenario as above, if you wanted to add 5G to the list of cellular networks, you would supply the following to your mutation call:

  • Cellular Network (Multi Select)
    • 3G
    • 4G
    • 5G

In this guide we’ll focus on Method 2 only - Method 1 is covered in the examples in this guide.

Examples

In this last section we’ll provide examples of how to use “Method 2 - Partial Option Type Updates” for the following scenarios:

    1. Update an existing single select option type with a new option value
    1. Add a new option value to an existing multi-select option type
    1. Remove an option value from an existing multi-select option type
    1. Remove all option values from an existing multi-select option type
    1. Update the value of a free-text option type

Mutations to use

You can use the following mutations to update option values

MutationUpdate AdvertsUpdate Variants
advertUpsertYesYes
variantUpdateNoYes

In the examples that follow, we’ll use advertUpsert to update Option Values at the Advert level, adapting these examples to update variants using either advertUpsert and variantUpdate should be straightforward as the constructs used are identical.

Prerequisite set up

As we are performing a range of updates, we’ll need an existing Advert to work with. Below we have used a node query to retrieve the relevant details of an existing advert:

To learn how to create adverts with the Seller API please refer to this article.

query ($id: ID!) {
  node(id: $id) {
    ... on Advert {
      id
      taxonNullable {
        treeName
        id
        prototype {
          id
          name
        }
      }
      advertOptionValues {
        totalCount
        nodes {
          id
          textValue
          optionType {
            id
            name
            optional
            fieldType
          }
          optionValue {
            name
          }
        }
      }
    }
  }
}

Variables

{
  "id": "QWR2ZXJ0LTEwMDA5NTgzNg=="
}

This query yields the following results:

{
 "data": {
   "node": {
     "id" : "QWR2ZXJ0LTEwMDA5NTgzNg==",
     "taxonNullable": {
       "treeName": "Cellular Technology - Cellular Phones",
       "id": "VGF4b24tMjgw",
       "prototype": {
         "id": "UHJvdG90eXBlLTEzNQ==",
         "name": "Cellular - Complex"
       }
     },
     "advertOptionValues": {
       "totalCount": 3,
       "nodes": [
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjYxMQ==",
           "textValue": null,
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNDg=",
             "name": "Cellular Network",
             "optional": false,
             "fieldType": "MULTI_SELECT"
           },
           "optionValue": {
             "name": "5G"
           }
         },
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjYxMg==",
           "textValue": "Snapdragon 12",
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNTA=",
             "name": "Cellular Processor",
             "optional": true,
             "fieldType": "FREE_TEXT"
           },
           "optionValue": null
         },
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjY0NA==",
           "textValue": null,
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNDY=",
             "name": "Cellular Material",
             "optional": true,
             "fieldType": "SINGLE_SELECT"
           },
           "optionValue": {
             "name": "Plastic"
           }
         }
       ]
     }
   }
 }
}

To summarize the relevant detail:

Option TypeField TypeOptionalOption Value(s)Text Value
Cellular NetworkMULTI_SELECTFalse5GN/a
Cellular ProcessorFREE_TEXTTrueN/aSnapdragon 12
Cellular MaterialSINGLE_SELECTTruePlasticN/a

NOTE: You’ll observe that for “Free Text” Option Types, we do not have any pre-defined Option Values, instead we supply a text value directly against the Option Type.

Retrieving available option values

As we are going to be updating the Option Values that we can assign to an Advert, we’ll want to understand what values we can provide. Looking back at the Advert we are working with, you can see we pulled the following detail:

  • prototype.id : UHJvdG90eXBlLTEzNQ==
  • prototype.name : Cellular - Complex

We can use the prototype.id with a node query to return all the option values that can be supplied for the option types assigned to this prototype as follows:

query GetOptionValuesAndTypesForPrototype {
  nodes(ids: "UHJvdG90eXBlLTEzNQ==") {
    ... on Prototype {
      id
      name
      optionTypes {
        nodes {
          id
          name
          fieldType
          appliedTo
          optional
          optionValues {
            nodes {
              id
              name
              displayName
            }
          }
        }
      }
    }
  }
}

This returns the following:

{
  "data": {
    "nodes": [
      {
        "id": "UHJvdG90eXBlLTEzNQ==",
        "name": "Cellular - Complex",
        "optionTypes": {
          "nodes": [
            {
              "id": "T3B0aW9uVHlwZS0yNDY=",
              "name": "Cellular Material",
              "fieldType": "SINGLE_SELECT",
              "appliedTo": "ADVERT",
              "optional": true,
              "optionValues": {
                "nodes": [
                  {
                    "id": "T3B0aW9uVmFsdWUtNzM0",
                    "name": "Plastic",
                    "displayName": "Plastic"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzM1",
                    "name": "Aluminium",
                    "displayName": "Aluminium"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzM2",
                    "name": "Carbon Fiber",
                    "displayName": "Carbon Fiber"
                  }
                ]
              }
            },
            {
              "id": "T3B0aW9uVHlwZS0yNDc=",
              "name": "Cellular Memory",
              "fieldType": "SINGLE_SELECT",
              "appliedTo": "VARIANT",
              "optional": false,
              "optionValues": {
                "nodes": [
                  {
                    "id": "T3B0aW9uVmFsdWUtNzMw",
                    "name": "64Gb",
                    "displayName": "64Gb"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzMx",
                    "name": "128Gb",
                    "displayName": "128Gb"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzMy",
                    "name": "256Gb",
                    "displayName": "256Gb"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzMz",
                    "name": "512Gb",
                    "displayName": "512Gb"
                  }
                ]
              }
            },
            {
              "id": "T3B0aW9uVHlwZS0yNDg=",
              "name": "Cellular Network",
              "fieldType": "MULTI_SELECT",
              "appliedTo": "ADVERT",
              "optional": false,
              "optionValues": {
                "nodes": [
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI2",
                    "name": "2G",
                    "displayName": "2G"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI3",
                    "name": "3G",
                    "displayName": "3G"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI4",
                    "name": "4G",
                    "displayName": "4G"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI5",
                    "name": "5G",
                    "displayName": "5G"
                  }
                ]
              }
            },
            {
              "id": "T3B0aW9uVHlwZS0yNDk=",
              "name": "Cellular Ports",
              "fieldType": "MULTI_SELECT",
              "appliedTo": "VARIANT",
              "optional": false,
              "optionValues": {
                "nodes": [
                  {
                    "id": "T3B0aW9uVmFsdWUtNzIz",
                    "name": "USB-C",
                    "displayName": "USB-C"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI0",
                    "name": "3.5 mm Headphone",
                    "displayName": "3.5 mm Headphone"
                  },
                  {
                    "id": "T3B0aW9uVmFsdWUtNzI1",
                    "name": "USB-B",
                    "displayName": "USB-B"
                  }
                ]
              }
            },
            {
              "id": "T3B0aW9uVHlwZS0yNTA=",
              "name": "Cellular Processor",
              "fieldType": "FREE_TEXT",
              "appliedTo": "ADVERT",
              "optional": true,
              "optionValues": {
                "nodes": []
              }
            },
            {
              "id": "T3B0aW9uVHlwZS0yNTI=",
              "name": "Cellular Color",
              "fieldType": "FREE_TEXT",
              "appliedTo": "VARIANT",
              "optional": false,
              "optionValues": {
                "nodes": []
              }
            }
          ]
        }
      }
    ]
  }
}

You will see that this has pulled back not only the option types appliedTo the ADVERT but also those appliedTo the VARAINT - again we’ll only be working with the Advert in this article, but the concepts for variants are identical.

Scenario 1: Update single select

In this scenario we want to update the single select option type for the Advert (Cellular Material) to a new option value:

  • Cellular Material Option Type: T3B0aW9uVHlwZS0yNDY=
  • Existing Option Value: Plastic (id = T3B0aW9uVmFsdWUtNzM0)
  • Update to Option Value: Aluminium (id = T3B0aW9uVmFsdWUtNzM1)
  • Advert Id: QWR2ZXJ0LTEwMDA5NTgzNg==

We’ll supply the relevant values to the advertUpsert mutation as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValuesPartial: [
          {
            optionTypeId: "T3B0aW9uVHlwZS0yNDY="
            optionValueId: "T3B0aW9uVmFsdWUtNzM1"
          }
        ]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

This will return with the following where we can see Cellular Material Option type has had its value updated - while all other option type values (Cellular Network, Cellular Processor) remain as-is.

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Network"
              },
              "optionValue": {
                "name": "5G"
              }
            },
            {
              "textValue": "Snapdragon 12",
              "optionType": {
                "name": "Cellular Processor"
              },
              "optionValue": null
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Material"
              },
              "optionValue": {
                "name": "Aluminium"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Scenario 2: Add a new option value to multi-select

In this scenario we want to update the multi select option type for the Advert (Cellular Network) to include a new additional option value:

  • Cellular Network Option Type: T3B0aW9uVHlwZS0yNDg=
  • Existing Option Value: 5G (id = T3B0aW9uVmFsdWUtNzI5)
  • Add Option Value: 4G (id = T3B0aW9uVmFsdWUtNzI4)
  • Advert Id: QWR2ZXJ0LTEwMDA5NTgzNg==

We’ll supply the relevant values to the advertUpsert mutation as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValuesPartial: [
          {
            optionTypeId: "T3B0aW9uVHlwZS0yNDg="
            optionValueIds: [
              "T3B0aW9uVmFsdWUtNzI4", 
              "T3B0aW9uVmFsdWUtNzI5"]
          }
        ]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

This will return the following, again note that because we were updating a multi select, we did still need to provide all values required:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Network"
              },
              "optionValue": {
                "name": "5G"
              }
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Network"
              },
              "optionValue": {
                "name": "4G"
              }
            },
            {
              "textValue": "Snapdragon 12",
              "optionType": {
                "name": "Cellular Processor"
              },
              "optionValue": null
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Material"
              },
              "optionValue": {
                "name": "Aluminium"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Scenario 3: Remove an existing option value from a multi-select

In this scenario we want to update the multi select option type for the Advert (Cellular Network) to remove the 4G option value

  • Cellular Network Option Type: T3B0aW9uVHlwZS0yNDg=
  • Existing Option Value: 5G (id = T3B0aW9uVmFsdWUtNzI5) - Supply to retain
  • Existing Option Value: 4G (id = T3B0aW9uVmFsdWUtNzI4) - Do not supply to remove
  • Advert Id: QWR2ZXJ0LTEwMDA5NTgzNg==

We’ll supply the relevant values to the advertUpsert mutation as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValuesPartial: [
          {
            optionTypeId: "T3B0aW9uVHlwZS0yNDg="
            optionValueIds: ["T3B0aW9uVmFsdWUtNzI5"]
          }
        ]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

This will return the following:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Network"
              },
              "optionValue": {
                "name": "5G"
              }
            },
            {
              "textValue": "Snapdragon 12",
              "optionType": {
                "name": "Cellular Processor"
              },
              "optionValue": null
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Material"
              },
              "optionValue": {
                "name": "Aluminium"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Scenario 4: Remove all option values from a multi-select

In this scenario we want to update the multi select option type for the Advert (Cellular Network) to remove option values:

  • Cellular Network Option Type: T3B0aW9uVHlwZS0yNDg=
  • Existing Option Value: 5G (id = T3B0aW9uVmFsdWUtNzI5) - Do not supply to remove
  • Advert Id: QWR2ZXJ0LTEwMDA5NTgzNg==

We’ll supply the relevant values to the advertUpsert mutation as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValuesPartial: [
          { optionTypeId: "T3B0aW9uVHlwZS0yNDg=", optionValueIds: [] }
        ]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

This will return as follows:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": "Snapdragon 12",
              "optionType": {
                "name": "Cellular Processor"
              },
              "optionValue": null
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Material"
              },
              "optionValue": {
                "name": "Aluminium"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Scenario 5: Update the value of a free-text option type

In this scenario we want to update the free text option type for the Advert (Cellular Processor) to a new text value:

  • Cellular Processor Option Type: T3B0aW9uVHlwZS0yNTA=
  • Existing free text value: Snapdragon 12
  • New free text value: Snapdragon 13
  • Advert Id: QWR2ZXJ0LTEwMDA5NTgzNg==

We’ll supply the relevant values to the advertUpsert mutation as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValuesPartial: [
          { 
            optionTypeId: "T3B0aW9uVHlwZS0yNTA=", 
            textValue: "Snapdragon 13" }
        ]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

This will return the following:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": "Snapdragon 13",
              "optionType": {
                "name": "Cellular Processor"
              },
              "optionValue": null
            },
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Material"
              },
              "optionValue": {
                "name": "Aluminium"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Removing other values

As Option Types can be defined as optional it is conceivable that you may on occasion want to resent / remove values assigned to them. As we have seen, you can do this using Method 2 for multi-select option types (scenario 6), but currently you cannot do this for either of the following option types as they always require a “value”:

  • Single Select
  • Free Text

To achieve this outcome you can use method 1 to either:

  1. Supply all the values you want to retain, remove those that you want to reset
  2. Remove all existing Option Values

We cover this approach to using “Method 1” in the 2 examples below

Prerequisites

As with method 2, lets work with an existing advert that has the following option types:

{
 "data": {
   "node": {
     "id" : "QWR2ZXJ0LTEwMDA5NTgzNg==",
     "taxonNullable": {
       "treeName": "Cellular Technology - Cellular Phones",
       "id": "VGF4b24tMjgw",
       "prototype": {
         "id": "UHJvdG90eXBlLTEzNQ==",
         "name": "Cellular - Complex"
       }
     },
     "advertOptionValues": {
       "totalCount": 3,
       "nodes": [
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjYxMQ==",
           "textValue": null,
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNDg=",
             "name": "Cellular Network",
             "optional": false,
             "fieldType": "MULTI_SELECT"
           },
           "optionValue": {
             "name": "5G"
           }
         },
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjYxMg==",
           "textValue": "Snapdragon 12",
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNTA=",
             "name": "Cellular Processor",
             "optional": true,
             "fieldType": "FREE_TEXT"
           },
           "optionValue": null
         },
         {
           "id": "QWR2ZXJ0T3B0aW9uVmFsdWUtNjY0NA==",
           "textValue": null,
           "optionType": {
             "id": "T3B0aW9uVHlwZS0yNDY=",
             "name": "Cellular Material",
             "optional": true,
             "fieldType": "SINGLE_SELECT"
           },
           "optionValue": {
             "name": "Plastic"
           }
         }
       ]
     }
   }
 }
}

To summarize the relevant detail:

Option TypeField TypeOptionalOption Value(s)Text Value
Cellular NetworkMULTI_SELECTFalse5GN/a
Cellular ProcessorFREE_TEXTTrueN/aSnapdragon 12
Cellular MaterialSINGLE_SELECTTruePlasticN/a

Scenario 1: Reset some option types

If we wanted to reset the values for:

  • Cellular Material (Single Select)
  • Cellular Processor (Free Text)

Then we could use Method 1 to supply the existing values for Cellular Network as follows:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: {
        advertOptionValues: [{ optionValueId: "T3B0aW9uVmFsdWUtNzI5" }]
      }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

Here we supplied only the Option Value Id for “5G” (Cellular Network) to retain that existing option value (we derived this from the prototype node query here).

This mutation would then respond with:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": [
            {
              "textValue": null,
              "optionType": {
                "name": "Cellular Network"
              },
              "optionValue": {
                "name": "5G"
              }
            }
          ]
        }
      },
      "errors": null
    }
  }
}

Here you can see the Single Select and Free Text Option Value assignments have been removed.

Scenario 2: Remove all option types

Following on from Scenario 1, our advert now only has option values assigned for a multi select option type, so you could use either Method 2 as specified here to completely remove these values, or use Method 1 as shown below:

mutation UpdateSingleSelectOptionValue {
  advertUpsert(
    input: {
      advertId: "QWR2ZXJ0LTEwMDA5NTgzNg=="
      attributes: { advertOptionValues: [] }
    }
  ) {
    status
    advert {
      id
      advertOptionValues {
        nodes {
          textValue
          optionType {
            name
          }
          optionValue {
            name
          }
        }
      }
    }
    errors {
      field
      messages
    }
  }
}

Supplying an empty collection to advertOptionValues removes all option values from the advert, and would return something like this:

{
  "data": {
    "advertUpsert": {
      "status": 200,
      "advert": {
        "id": "QWR2ZXJ0LTEwMDA5NTgzNg==",
        "advertOptionValues": {
          "nodes": []
        }
      },
      "errors": null
    }
  }
}

Note: in this example we only had values for 1 option type, however you can apply this method to any advert with many more option value assignments and it will remove them all.