Skip to content

[bug] errors messages are hard-coded in englishΒ #3542

@iambumblehead

Description

@iambumblehead

https://github.com/graphql/graphql-js/blob/main/src/validation/rules/ProvidedRequiredArgumentsRule.ts#L50-L52

new GraphQLError(
    `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`,
     { nodes: fieldNode },
),

The error messages should, in some way, be customizable and i18n friendly. Typically, an express or koa service uses the 'Accept-Language' header to determine the message language,

const locale = ctx.get( 'accept-language' ) || 'en-US';

Using npm packages i18next, i18n or nanostores/i18n a message is ultimately rendered in the following way,

i18nMessage( locale, messageKey, { fieldDefName, argDefName, argTypeStr });

Customizing error messages is mostly impractical at the moment due to overly complicated work-arounds needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions