Mutation companyLocationUpdate - buyerExperienceConfiguration

Hi,

I am trying to update the deposit percentage as part of the buyerExperienceConfiguration on company location.

I’m not a specialist of graphQL yet. I first tried something simple which was

{
  "query": "mutation UpdateCompanyLocation { companyLocationUpdate(companyLocationId: \"gid://shopify/CompanyLocation/1479934290\", input: { buyerExperienceConfiguration: { deposit: { percentage: 20 } } }) { companyLocation { id buyerExperienceConfiguration { deposit { ... on DepositPercentageConfiguration { percentage } } } } userErrors { field message code } } }",
  "variables": {
    "companyLocationId": "gid://shopify/CompanyLocation/1479934290",
    "depositPercentage": 20
  }
}

But this returned an error [200] “Error(s): selectionMismatch - Selections can’t be made directly on unions (see selections on DepositConfiguration)”

Then the AI Shopify developer assistant suggested me to use an “inline fragment” and to try this instead :

mutation UpdateCompanyLocation {
  companyLocationUpdate(
    companyLocationId: "gid://shopify/CompanyLocation/1479934290",
    input: {
      buyerExperienceConfiguration: {
        deposit: { percentage: 20 }
      }
    }
  ) {
    companyLocation {
      id
      buyerExperienceConfiguration {
        deposit {
          ... on DepositPercentageConfiguration {
            percentage
          }
          # Add other fragments here if you want to handle other deposit types
        }
      }
    }
    userErrors {
      field
      message
      code
    }
  }
}

But that doesn’t work either, I get this error : “[200] Error(s): undefinedType - No such type DepositPercentageConfiguration, so it can’t be a fragment condition”

Anyone could help me getting my mutation right please?

Thanks.

Let’s take a look at the documentation.

It says that deposit is of type, DepositConfiguration. Deposit configuration is indeed a union type, so you will need to use a fragment in order to get any fields out of it.

Looking at the docs for DepositConfiguration, you can see that there is only one type that it can be, which is DepositPercentage, this type has a field percentage, which is what you want to get.

As you can see the AI suggested that the fragment be on DepositPercentageConfiguration, which does not exist, instead the correct type name is just DepositPercentage.

Hi @Guillaume_B

Did this work using DepositPercentage as suggested by @SRCB ?

Hi @Liam-Shopify , yes it did ! Thanks @SRCB