Skip to content

Lexographically sorted printSchema for comparison/diff stability? #941

@benjie

Description

@benjie

printSchema already sorts the type names alphabetically:

.sort((name1, name2) => name1.localeCompare(name2))

It would also be useful for diffing if fields, arguments, enum values and various other entities were also sorted alphabetically. I have performed some local modifications and it seems the changes required are quite minor. However, I believe it's possibly the case that a schema sorted in one way is not identical to a schema sorted in another because the order of fields/arguments may affect the order in which they are resolved?

I therefore have the following questions:

  1. Would ordering the printSchema alphabetically by default be an acceptable change?
  2. If not, would it be acceptable to add a second argument added to printSchema that supports an enumeration of sort modes (e.g. 'natural' for the current ordering, 'alphabetic', and even something more exotic like ordering by heirarchy as in Add printFineSchema() for printing hierarchy ordered types. #281)?
  3. Would you accept a pull request to add these changes?

Keywords (to help others find this issue, also detailing what I searched for before): alphabetic, lexographic, lexical, order, sort, printSchema, print, stable

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