There are no consistency between locales ISO code in the Graphql API response and webhook response

I just realized that there are no consistency in the response for locale ISO codes between Graphql and the webhook HTTP body response:

for example in webhook is en-GB and in Graphql is en_GB, see the image below:

Not sure if this is a bug or is intended. My issue is that Iā€™m mapping the locales to have specific locale codes in my slug but is hard to map if I received different versions from Dato:

export const mapDatoLocaleToLocale: Record<SiteLocale, Locales> = {
  de: "de-de",
  en_GB: "en-gb",
  nl_NL: "nl-nl",
  fr: "fr-fr",
};

Hello @gerald and welcome to Community.

Sorry for the delay here, but the dash is not an allowed character in GraphQL for enums :frowning:

You should replace dashes with underscores and it should be consistent.

1 Like