Skip to content

Get Country

About

The country query retrieves detailed information about a single country by its ID. Use this query to:

  • Display country-specific information and settings
  • Fetch all states/provinces for a country
  • Get country translations for multi-language support
  • Populate address forms with state options for a selected country
  • Build country-specific pages and configurations
  • Display country-specific shipping rules
  • Render localized country and state names

This query returns comprehensive country data including all states with translations and country translations for multiple languages.

Arguments

ArgumentTypeDescription
idID!Country ID in format "106" or "/api/shop/countries/106".

Possible Returns

FieldTypeDescription
idID!Unique country API identifier.
_idInt!Numeric country ID.
codeString!ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB', 'AE').
nameString!Country name in default language.
statesCountryStateCollection!States/provinces for this country.
states.edges[Edge!]!State edges with cursors.
states.edges.nodeCountryState!Individual state information.
states.edges.node.idID!State API identifier.
states.edges.node._idInt!Numeric state ID.
states.edges.node.codeStringState code (e.g., 'CA' for California).
states.edges.node.defaultNameString!State name in default language.
states.edges.node.countryIdInt!Associated country ID.
states.edges.node.countryCodeString!Associated country code.
states.edges.node.translationsStateTranslationCollection!All state translations.
states.edges.node.translations.edges[Edge!]!Translation edges.
states.edges.node.translations.edges.node.idID!Translation ID.
states.edges.node.translations.edges.node.localeString!Language locale code.
states.edges.node.translations.edges.node.defaultNameString!Translated state name.
states.pageInfoPageInfo!Pagination info for states.
states.pageInfo.hasNextPageBoolean!More states available.
states.pageInfo.endCursorStringLast state cursor.
states.totalCountInt!Total states for this country.
translationsCountryTranslationCollection!All country translations.
translations.edges[Edge!]!Translation edges with cursors.
translations.edges.nodeCountryTranslation!Individual translation.
translations.edges.node.idID!Translation identifier.
translations.edges.node._idInt!Numeric translation ID.
translations.edges.node.localeString!Language locale code.
translations.edges.node.nameString!Country name in locale language.
translations.edges.cursorString!Pagination cursor.
translations.pageInfoPageInfo!Pagination info for translations.
translations.totalCountInt!Total translations for this country.

Use Cases

1. Address Form State Selection

Use the "With States" example to populate state dropdown when user selects a country.

2. Multi-Language Display

Use the "With Translations" example to display country name in user's language.

3. Country Details Page

Use the "Complete Details" example for a comprehensive country information display.

Best Practices

  1. Cache Country Data - Country information rarely changes, cache the response
  2. Load States Dynamically - Fetch states when user selects a country in forms
  3. Include Translations - Always fetch translations for multi-language support
  4. Handle No States - Some countries have no states configured, handle gracefully
  5. Use Correct ID - Use numeric ID format "106" or full API path

Released under the MIT License.