PHP 7.3 reaches end of support in December 2021 and Adobe Commerce 2.3.x reaches end of support in April 2022. You may want to consider planning your upgrade now to Adobe Commerce 2.4.x and PHP 7.4.x to help maintain PCI compliance.

country query

Use the country query to retrieve information about a specific country.

Use the countries query to retrieve a list of countries available in the system.

Syntax

{country(id: String) {Country}}

Example usage

The following query uses a two-letter abbreviation for the country ID (id: “AU”), which returns information about Australia.

Request:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
query {
    country(id: "AU") {
        id
        two_letter_abbreviation
        three_letter_abbreviation
        full_name_locale
        full_name_english
        available_regions {
            id
            code
            name
        }
    }
}

Response:

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
{
  "data": {
    "country": {
      "id": "AU",
      "two_letter_abbreviation": "AU",
      "three_letter_abbreviation": "AUS",
      "full_name_locale": "Australia",
      "full_name_english": "Australia",
      "available_regions": [
        {
          "id": 569,
          "code": "ACT",
          "name": "Australian Capital Territory"
        },
        {
          "id": 570,
          "code": "NSW",
          "name": "New South Wales"
        },
        {
          "id": 576,
          "code": "NT",
          "name": "Northern Territory"
        },
        {
          "id": 572,
          "code": "QLD",
          "name": "Queensland"
        },
        {
          "id": 573,
          "code": "SA",
          "name": "South Australia"
        },
        {
          "id": 574,
          "code": "TAS",
          "name": "Tasmania"
        },
        {
          "id": 571,
          "code": "VIC",
          "name": "Victoria"
        },
        {
          "id": 575,
          "code": "WA",
          "name": "Western Australia"
        }
      ]
    }
  }
}

Input attributes

The country query requires the following input:

Attribute Data type Description
id String A unique ID for the country

Output attributes

The query returns a single Country object.

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

Errors

Error Description
Country \"id\" value should be specified" The Country ID value must be specified to find the mapped country.
The country isn't available There is no country mapped to the given country ID.