Skip to content

Allow specifying locale in lexicographicSortSchema #2869

@vhenzl

Description

@vhenzl

I use lexicographicSortSchema() to get a stable output when generating TS types from GraphQL schema and recently I discovered a problem when a field called chemicalName is misplaced and causing a diff.

The reason is that one of my machines has non-English, Czech locale and in Czech alphabet, the digraph Ch is handled as a single letter and sorted between H and I.

Example
const items = ['xx', 'aa', 'dd', 'cx', 'ch', 'cc'];

items.sort((a, b) => a.localeCompare(b, 'en'));
// ["aa", "cc", "ch", "cx", "dd", "xx"]

items.sort((a, b) => a.localeCompare(b, 'cs'));
// ["aa", "cc", "cx", "dd", "ch", "xx"]

Would be great if lexicographicSortSchema() could accept locales and possibly also options parameters for localeCompare to be able to force a particular (English) locale for the schema sorting independently on the machine's locale.

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