daun / statamic-graphql-alternate-locales
List alternate locales of entries in Statamic GraphQL queries.
Installs: 91
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:statamic-addon
Requires
- php: ^8.1
- statamic/cms: ^4.0 || ^5.0
README
List alternate locales of entries in Statamic GraphQL queries.
This addon provides a simple way of querying alternate languages of entries in GraphQL. Mainly useful for frontend language switches.
Installation
composer require daun/statamic-graphql-alternate-locales
Usage
After installation, you can list all locales of an entry from the new locales
field. It requires
selecting the specific subfields to return. See below for a list of all supported subfields.
{ page: entry( collection: "pages" slug: "about" filter: { locale: "en" } ) { slug title locale locales { locale slug title } } }
The above query would result in the following data:
{ "slug": "about", "title": "About", "locale": "en", "locales": [ { "locale": "de", "slug": "ueber-uns", "title": "Über uns" }, { "locale": "en", "slug": "about", "title": "About" } ] }
Publish status
By default, the locales
field only returns entries in published locales. To include all locales
regardless of publish status, set the unpublished
arg to true
:
locales (unpublished: true) { locale slug title }