Help Needed: 400 Error with "Invariant Failed" on Shopify customerAddressUpdate Mutation

Help Needed: 400 Error with "Invariant Failed" on Shopify customerAddressUpdate Mutation

Shilpe_Saxena
Visitor
2 0 0

Hi Shopify Community,

I’m encountering an issue with the Shopify customerAddressUpdate mutation and need your assistance. I receive a 400 error with the message "Invariant Failed" when attempting to update or create an address using the Shopify API.

Here’s a summary of the problem:

  • Mutation Used: customerAddressUpdate
  • Error: 400 Bad Request, "Invariant Failed"
  • Issue: Despite providing the correct payload and ensuring that the mutation fields match Shopify’s API documentation, the error persists.

    Details:

    • GraphQL Mutation Query:

 

mutation customerAddressUpdate(
  $address: CustomerAddressInput!
  $addressId: ID!
  $defaultAddress: Boolean
) {
  customerAddressUpdate(
    address: $address
    addressId: $addressId
    defaultAddress: $defaultAddress
  ) {
    customerAddress {
      id
      firstName
      lastName
      address1
      city
      province
      country
      zip
    }
    userErrors {
      code
      field
      message
    }
  }
}


Example Payload:

 

 

 

 

{
  "address": {
    "firstName": "xtz",
    "lastName": "adfsa",
    "company": "compose tech",
    "address1": "55 Garden Place",
    "address2": "Willoughby",
    "city": "Willoughby",
    "province": "New South Wales",
    "country": "AU",
    "zip": "2068",
    "phone": ""
  },
  "addressId": "your-address-id",
  "defaultAddress": false
}

 

 

 

Headers Used in Postman:

  • Content-Type: application/json
  • X-Shopify-Access-Token: your-access-token

Steps Taken:

  1. Verified that the GraphQL mutation and variables are correctly defined.
  2. Checked the format and values of the address data.
  3. Tested the mutation in GraphQL Playground with similar results.

Questions:

  1. Has anyone encountered a similar "Invariant Failed" error with this mutation?
  2. Are there specific requirements or constraints for the address object that might not be immediately obvious?
  3. Any tips on how to better debug or resolve this issue?

I appreciate any guidance or suggestions you can offer. Thank you!

Best regards,
Shilpe Saxena

Replies 2 (2)

Kyle_liu
Shopify Partner
178 26 29

Hi @Shilpe_Saxena 

 

customerAddressUpdate (shopify.dev)

 

I noticed that your parameters are not correct.

If this is helpful, please Like and Accept the solution.
Want to modify or custom changes on store? Let me help.
- Feel free to contact me on ([email protected])
Shilpe_Saxena
Visitor
2 0 0

Hi @Kyle_liu ,

The solution did not resolve the issue. Even after adjusting the query to match the expected fields, I am still encountering the same error message: "Expected customer address to be updated."

Shilpe_Saxena_0-1726642483390.png