Province vs provinceCode in MailingAddressInput

The documentation online for all available graphql API versions mentions province as a field on MailingAddressInput, which is what we’ve been using.

But if I run an introspection query against 2024-01 or later in the Shopify GraphiQL app to grab the schema, it’s showing that province is gone and instead there is provinceCode

just wondering which is correct and if it’s provinceCode, how does that relate to province that we were using previously? Can we put the full province (state) name in there? or not?

The documentation

the GraphiQL inspected docs from the schema

You are comparing two different APIs. In the docs screenshot, you appear to be looking at the Storefront API 2024-01, but then in Shopify GraphiQL App, using the Admin API. Beyond versions, these different APIs have slightly different definitions for MailingAddressInput.

In 2018, Admin API introduced provinceCode as a more precise province input to solve issues related to internationalized values (i.e. using a localized variation of a province name vs the Anglicized variation).

Admin’s province is deprecated but still valid for backwards compatibility. GraphiQL is not showing deprecated input fields. Introspection queries may not be asking for deprecated fields, depends on how the query was written.

1 Like

Appreciate the response Rob!

I’m looking at SubscriptionDeliveryMethodShippingInput - GraphQL Admin which references MailingListInput

in 2024-01 there was a province field, now it’s provinceCode. In 2024-04 provinceCode seems to be required now when modifying subscription contracts. This wasn’t documented anywhere in the breaking changes 2024-04 release notes

Hi @Rob-Shopify . I also faced some issues with provinceCode issue as well. I’ve tried to seek for the provinceCode document to get the full list provinceCode of all countries. Can you please provide me this docs? Thank you so much in advanced.

I do not believe there is such a list. Different parts of the API accept/return country/province values, but there is no globally defined list of allowed values at this time to my knowledge.

There is Shop.shipsToCountries, but that only gives you some country codes.

Closest that comes to mind is Admin REST API’s countries used for tax purposes which does not have a GraphQL equivalent.

@hue_nguyen we ended up using the geodb citites API because we were already making use of it in other parts of our app. The specific endpoint we’re using is the find-regions one.

It’s fairly inexpensive, they even offer a self-hosted option with no request limits if you need massive scale.

The API is backed by the actual ISO 3166-2 standard but I think it’s more expensive to subscribe to the official dataset. Just want to mention it because that could be another route if you want to manage it without an external API.

Example:

curl http://geodb-free-service.wirefreethought.com/v1/geo/countries/US/regions?namePrefix=Maryland

Results in:

{
  "data": [
    {
      "countryCode": "US",
      "fipsCode": "24",
      "isoCode": "MD",
      "name": "Maryland",
      "wikiDataId": "Q1391"
    }
  ],
  "metadata": {
    "currentOffset": 0,
    "totalCount": 1
  }
}

Hi, thank you so much for answering me. Shopify does provide a list of country code, but not Province code, so I posted my question before. Now I understand that there’s no official docs about Province code, but it’s based on ISO standard.

Hi @josephtaylor. Thank you so much for the detail support. I see that there are some different ways to get this Province code list. However, I don’t know very well about technical solution, so I will send your suggestion to our engineers. Thank you again.