Storefront GraphQL API get list of available countries and states/provinces

shadtek
Shopify Partner
2 0 5

 

How do I get a list of the countries and their states/provinces with the Storefront GraphQL API?

I am creating a page in React where a customer can edit their address. I want to use the Storefront GraphQL API because that is what all of the other queries in my React site are written with.

I tried this query but it looks like the states/provinces are not available to be retrieved. Why are the states/provinces not available here?


https://shopify.dev/api/storefront/2022-01/objects/Country#fields

 

{
  localization {
    availableCountries {
      name
    }
  }
}

 

 

Screen Shot 2022-03-18 at 10.25.56 AM.png

 

Replies 3 (3)

masabmehmood
Visitor
2 0 0

Hi

did you get any solution to fetch the states/Province

 

mason225
Shopify Partner
4 0 0

Did you found the solution? I'm stucking on this also.

Michael_Tot
Visitor
3 0 0