i18n Concerns

The GraphQL Specification (https://spec.graphql.org/October2021/#sec-Names) requires that names of fields and types use only a subset of ASCII characters. On the other hand the GraphQL viewer will infer these fields from the Java domain objects, which permits a wider range of characters.

To ensure that only permitted characters are used in the GraphQL model, provide an implementation of the AsciiIdentifierService.

For example, suppose this class is part of the domain:

I18nCalculator
@Named("university.calc.I18nCalculator")
@DomainService
@Priority(PriorityPrecedence.EARLY)
@RequiredArgsConstructor(onConstructor_ = {@Inject})
public class I18nCalculator {

    @Action(semantics = SemanticsOf.SAFE)
    public String concät(
            String ä1,
            String ä2) {
        return ä1 + ä2;
    }
}

As this service uses a non-ASCII character, ä, we need to provide a service to convert it:

AsciiIdentifierServiceSupportingGraphqlViewer
@Service
public class AsciiIdentifierServiceSupportingGraphqlViewer
    implements AsciiIdentifierService {

    public String asciiIdFor(String featureId) {
        return featureId.replace("ä", "a");
    }
}

This implementation could be fairly easily be extended for other Latin languages, but non-Latin languages such as Kanji would obviously need a more sophisticated implementation.