How to Get Available Stores Using GraphQL in Magento 2

Do you want to know how to get list of all the available stores information using GraphQL Query in Magento 2?

In this Magento 2 GraphQL Tutorial, We will show how to get list of all the available stores information using GraphQL Query in Magento 2. We will use the {availableStores} query to get available stores information.

Let’s start!

Get Available Stores Query:

The {availableStores} query returns configuration information about multiple store views. You can use this query to implement a store switcher.

query {
  availableStores(useCurrentGroup: true) {
    store_code
    store_name
    is_default_store
    store_group_code
    is_default_store_group
    locale
    base_currency_code
    default_display_currency_code
    timezone
    weight_unit
    base_url
    base_link_url
    base_static_url
    base_media_url
    secure_base_url
    secure_base_link_url
    secure_base_static_url
    secure_base_media_url
  }
}

Output:

{
  "data": {
    "availableStores": [
      {
        "store_code": "default",
        "store_name": "Default Store View",
        "is_default_store": true,
        "store_group_code": "main_website_store",
        "is_default_store_group": true,
        "locale": "en_US",
        "base_currency_code": "USD",
        "default_display_currency_code": "USD",
        "timezone": "America/Chicago",
        "weight_unit": "lbs",
        "base_url": "http://example.com/",
        "base_link_url": "http://example.com/",
        "base_static_url": "http://example.com/pub/static/version1606976517/",
        "base_media_url": "http://example.com/pub/media/",
        "secure_base_url": "http://example.com/",
        "secure_base_link_url": "http://example.com/",
        "secure_base_static_url": "http://example.com/pub/static/version1606976517/",
        "secure_base_media_url": "http://example.com/pub/media/"
      },
      {
        "store_code": "de",
        "store_name": "Europe Store View",
        "is_default_store": false,
        "store_group_code": "main_website_store",
        "is_default_store_group": true,
        "locale": "de_DE",
        "base_currency_code": "USD",
        "default_display_currency_code": "EUR",
        "timezone": "Europe/Berlin",
        "weight_unit": "lbs",
        "base_url": "http://example.com/",
        "base_link_url": "http://example.com/",
        "base_static_url": "http://example.com/pub/static/version1606976517/",
        "base_media_url": "http://example.com/pub/media/",
        "secure_base_url": "http://example.com/",
        "secure_base_link_url": "http://example.com/",
        "secure_base_static_url": "http://example.com/pub/static/version1606976517/",
        "secure_base_media_url": "http://example.com/pub/media/"
      }
    ]
  }
}

In this example, You will get information about all the available stores of your Magento instance.


You can use ChromeiQL tool to test and run GraphQL Query in Magento 2.

How to Get Available Stores Using GraphQL in Magento 2 Click To Tweet

If you liked this tutorial, then please subscribe to our Newsletter for Magento tutorials. You can also find us on Twitter and Facebook. If you have any problem or would like to add to the discussion, leave a comment below!

You May Also Like

Editorial Staff

About the Author: Editorial Staff

Editorial Staff at the MageBeginners is a team of Magento experts writing about Magento Tutorials, Themes, Extensions, Guides, Tricks and much more...

Leave a Reply

Your email address will not be published. Required fields are marked *