Back to Content Management API

locales

Returns your store's locales, newest first, paginated by a cursor. Inactive locales are included; check active. Use a locale's id as the localeId for the *Translate mutations.

Arguments

  • Name
    after
    Type
    String
    Description

    Returns the elements that come after the specified cursor.

  • Name
    before
    Type
    String
    Description

    Returns the elements that come before the specified cursor.

  • Name
    first
    Type
    Int
    Description

    Returns up to the first n elements, at most 25.

  • Name
    last
    Type
    Int
    Description

    Returns up to the last n elements, at most 25.

  • Name
    version
    Type
    Version
    Description

    Accepted for consistency with other list queries; it doesn't change the results.

Returns

  • Name
    LocaleConnection.edges
    Type
    [LocaleEdge!]!
    Description

    A list of edges.

  • Name
    LocaleConnection.nodes
    Type
    [Locale!]!
    Description

    A list of locales. Any requested field from the Locale object.

  • Name
    LocaleConnection.pageInfo
    Type
    PageInfo!
    Description

    Information to aid in pagination.

  • Name
    LocaleConnection.totalCount
    Type
    Int!
    Description

    The number of locales in your store.

Request

import { PackClient } from '@pack/client'
const packClient = new PackClient({
  token: 'YOUR-PACK-TOKEN'
});

const query = `
  query Locales($first: Int) {
    locales(first: $first) {
      nodes {
        id
        languageCode
        countryCode
        isPrimary
        active
      }
      totalCount
    }
  }
`;

const variables = {
  first: 25
};
const response = await packClient.fetch(query, { variables: variables });
console.log(response.data);

Response

{
    "data": {
        "locales": {
            "nodes": [
                {
                    "id": "YOUR-LOCALE-ID",
                    "languageCode": "fr",
                    "countryCode": "CA",
                    "isPrimary": false,
                    "active": true
                },
                {
                    "id": "YOUR-PRIMARY-LOCALE-ID",
                    "languageCode": "en",
                    "countryCode": "US",
                    "isPrimary": true,
                    "active": true
                }
            ],
            "totalCount": 2
        }
    }
}

Was this page helpful?