Updating a Shipping Zone using GraphQL

Solved
Lemonn
New Member
3 1 2

Hi, I'm attempting to manage and change the shipping zone and rate for a Shipping Profile. My GraphQL query looks like this:

 

mutation { 
                deliveryProfileUpdate(
                    id: "{dp_id}",
                    profile: {
                        locationGroupsToUpdate: [{
                            zonesToUpdate: [{
                                countries: [{
                                    code: US
                                    provinces: [{code: "AK"},
                                                {code: "AS"},
                                                {code: "GU"},
                                                {code: "HI"},
                                                {code: "MP"},
                                                {code: "PR"},
                                                {code: "VI"},
                                                {code: "FM"},
                                                {code: "PW"},
                                                {code: "MH"},
                                                {code: "AA"},
                                                {code: "AE"},
                                                {code: "AP"
                                }]
                            }]
                        }]
                    }]
                 }
              )
                  {
                      profile {
                          id
                      }               
                      userErrors {
                          field
                          message
                      }
                  }
              }

 

 

The response I print out is the following:

 

{"data":{"deliveryProfileUpdate":{"profile":null,"userErrors":[{"field":null,"message":"Profile is invalid: ID must be present during an update."}]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":100
0.0,"currentlyAvailable":990,"restoreRate":50.0}}}}

 

 

And the GID I pass in the query is this:

 

"gid://shopify/DeliveryProfile/75937513680"

 

 

What I'm trying to do is remove the states in the `provinces` list from the already existing "Domestic" shipping profile. Why am I getting an ID error? Am I even using the correct query/fields to update a `DeliveryProfile`'s zones? I'd appreciate any insight.

Lemonn
New Member
3 1 2

This is an accepted solution.

Update: Fixed it, you needed the `locationGroup` and `locationGroupZone` IDs for this to work.

This is the working query:

 

mutation {
                deliveryProfileUpdate(
                    id: "{dp_id}",
                    profile: {
                        locationGroupsToUpdate: [{
                            id: "{lg_id}",
                            zonesToUpdate: [{
                                id: "{lgz_id}",
                                name: "Domestic",
                                countries: [{
                                    code: US
                                    provinces: [{code: "AK"},
                                                {code: "AS"},
                                                {code: "GU"},
                                                {code: "HI"},
                                                {code: "MP"},
                                                {code: "PR"},
                                                {code: "VI"},
                                                {code: "FM"},
                                                {code: "PW"},
                                                {code: "MH"},
                                                {code: "AA"},
                                                {code: "AE"},
                                                {code: "AP"
                                }]
                            }]
                        }]
                    }]  
                }
            )
                {
                    profile {
                        id
                    }              
                    userErrors {
                        field
                        message
                    }
                }
            }

 

 

Where `dp_id` is the `deliveryProfile` ID, and `lg_id` and `lgz_id` are the `locationGroup` and `locationGroupZone` IDs respectively. This particular code updates the profile to only include the 13 states listed.