Absinthe Error handling and Gettext

Hello guys,

I would like to talk here about error handling in connection with absinthe and gettext. Maybe someone has a similar problem and will find it here :slight_smile:

Following use case:
There is a phoenix app that provides a graphql endpoint via absinthe. This endpoint is accessed via a textual (command line tool) and a graphical user interface (another phoenix app).

Now, the graphql endpoint must, in case of an error, send an adequate error message to the user. Ideally this error message should be localized. My idea here is to return the error message in English as well as in the localized language. Especially API errors that consist of interpolated parts. For example you could send back an error like this:

    kind: ERROR,
    message: "The user %s is already registered."
    params: ["foo"],
    locale: "de_DE",
    message_l10n: "Der Benutzer %s ist bereits registriert."
    message_l10n: "The user %s is already registered."

The difficult thing about this error handling is that it has to be integrated framework-like as middleware or hook in each resolver. In addition, the software no longer follows the principle of โ€œlet it crashโ€, since every runtime error must return an adequate error message. In particular, we leverage the internal Absinthe error messages. I have seen that there are already similar projects like Blunder โ€“ Blunder v1.1.1 .

But this is too technical for normal API users. I wonder if any of you are already dealing with this topic or know best practices.

Do you think it makes sense to localize API errors at all?