Get Single Locale
About
The locale query retrieves a single locale by ID with support for detailed field access. This query is essential for:
- Fetching specific locale details for UI configuration
- Checking text direction (LTR/RTL) for layout adjustments
- Retrieving locale-specific branding and logos
- Validating locale existence before operations
- Building locale detail pages
- Configuring locale-specific settings
The query allows you to fetch a specific locale with all its properties and relationships.
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
id | ID! | ✅ Yes | The unique identifier of the locale. Can be either numeric ID or IRI format (/api/shop/locales/{id}). |
Possible Returns
| Field | Type | Description |
|---|---|---|
locale | Locale | The requested locale object, or null if not found. |
Locale Fields
| Field | Type | Description |
|---|---|---|
id | String! | Unique identifier in format /api/shop/locales/{id} |
_id | Int! | Numeric identifier for the locale |
code | String! | Unique locale code (e.g., "en", "ar", "fr", "de") |
name | String! | Display name of the locale (e.g., "English", "Arabic") |
direction | String! | Text direction: "ltr" (left-to-right) or "rtl" (right-to-left) |
logoPath | String | File path to the locale logo (e.g., "locales/en.png") |
Common Use Cases
Get Locale Details by IRI ID
graphql
query GetLocaleByIRI($id: ID!) {
locale(id: $id) {
id
_id
code
name
direction
logoPath
}
}Variables:
json
{
"id": "/api/shop/locales/1"
}Get Locale with Logo and Timestamps
graphql
query GetLocaleDetails($id: ID!) {
locale(id: $id) {
id
code
name
direction
logoPath
}
}Check If Locale is RTL
graphql
query GetLocaleDirection($id: ID!) {
locale(id: $id) {
code
name
direction
}
}Validate Locale Existence
graphql
query ValidateLocale($id: ID!) {
locale(id: $id) {
id
code
}
}Error Handling
Locale Not Found
json
{
"data": {
"locale": null
}
}Missing Required ID Parameter
json
{
"errors": [
{
"message": "Field \"locale\" argument \"id\" of type \"ID!\" is required but not provided."
}
]
}Invalid ID Format
json
{
"errors": [
{
"message": "Invalid ID format. Expected IRI format like \"/api/shop/locales/1\" or numeric ID"
}
]
}Best Practices
- Always Provide ID - The ID parameter is required for this query
- Check for Null - Handle the case when locale is not found (returns null)
- Use Direction Field - Always check the
directionfield for proper UI layout - Cache Results - Locales change infrequently; implement caching
- Validate Before Using - Verify locale exists before using in operations
- Use Variables - Use GraphQL variables for dynamic locale queries
- Request Needed Fields - Only request fields you'll actually use
- Handle RTL Properly - Apply appropriate CSS classes based on direction
Related Resources
- Get Locales - Retrieve all locales with pagination
- Pagination Guide - Cursor pagination documentation
- Shop API Overview - Overview of Shop API resources
- Authentication Guide - Authentication and authorization

