This is a beta release of documentation for Magento 2.4, published for previewing soon-to-be-released functionality. Content in this version is subject to change. Links to the v2.4 code base may not properly resolve until the code is officially released.

countries query

Use the countries query to return all countries in which the entity can do business.

Syntax

{countries {Countries}}

Example usage

The following query returns all countries listed for the current instance of Magento:

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
query {
    countries {
        id
        two_letter_abbreviation
        three_letter_abbreviation
        full_name_locale
        full_name_english
        available_regions {
            id
            code
            name
        }
    }
}

Response:

In this example, the response is intentionally truncated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{
  "data": {
    "countries": [
      {
        "id": "AD",
        "two_letter_abbreviation": "AD",
        "three_letter_abbreviation": "AND",
        "full_name_locale": "Andorra",
        "full_name_english": "Andorra",
        "available_regions": null
      },
      {
        "id": "AE",
        "two_letter_abbreviation": "AE",
        "three_letter_abbreviation": "ARE",
        "full_name_locale": "United Arab Emirates",
        "full_name_english": "United Arab Emirates",
        "available_regions": null
      },
      {
        "id": "AF",
        "two_letter_abbreviation": "AF",
        "three_letter_abbreviation": "AFG",
        "full_name_locale": "Afghanistan",
        "full_name_english": "Afghanistan",
        "available_regions": null
      },
      {
        "id": "AG",
        "two_letter_abbreviation": "AG",
        "three_letter_abbreviation": "ATG",
        "full_name_locale": "Antigua and Barbuda",
        "full_name_english": "Antigua and Barbuda",
        "available_regions": null
      },
      {
        "id": "AT",
        "two_letter_abbreviation": "AT",
        "three_letter_abbreviation": "AUT",
        "full_name_locale": "Austria",
        "full_name_english": "Austria",
        "available_regions": [
          {
            "id": 102,
            "code": "BL",
            "name": "Burgenland"
          },
          {
            "id": 99,
            "code": "KN",
            "name": "Kärnten"
          },
          {
            "id": 96,
            "code": "NO",
            "name": "Niederösterreich"
          },
          {
            "id": 97,
            "code": "OO",
            "name": "Oberösterreich"
          },
          {
            "id": 98,
            "code": "SB",
            "name": "Salzburg"
          },
          {
            "id": 100,
            "code": "ST",
            "name": "Steiermark"
          },
          {
            "id": 101,
            "code": "TI",
            "name": "Tirol"
          },
          {
            "id": 103,
            "code": "VB",
            "name": "Vorarlberg"
          },
          {
            "id": 95,
            "code": "WI",
            "name": "Wien"
          }
        ]
      }
    ]
  }
}

Output attributes

The query returns an array of Country objects.

Country attributes

Attribute Data type Description
available_regions [Region] An array of regions within a particular country
full_name_english String The name of the country in English
full_name_locale String The locale name of the country
three_letter_abbreviation String The three-letter abbreviation of the country, such as USA
two_letter_abbreviation String The two-letter abbreviation of the country, such as US

Region attributes

The Region object provides the following attributes:

Attribute Data type Description
code String The two-letter code for the region, such as TX for Texas
id Int A unique ID for the region
name String The name of the region, such as Texas