Skip to content

Add SDLSorter #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2023
Merged

Add SDLSorter #327

merged 1 commit into from
Jun 24, 2023

Conversation

Shane32
Copy link
Member

@Shane32 Shane32 commented Jun 19, 2023

This PR adds another visitor implementation to sort a SDL -- that is, to walk the tree and sort each list of nodes that are encountered. Some node types, such as comments and literal arrays, are left in their original order. Fortunately the implementation turned out to be quite simple to implement. This implementation has a fixed sort order, generally by name ascending, but the string comparison used can be selected, with culture-invariant case-insensitive as default. It can sort execution or definition documents. Of course, execution documents will execute differently since the execution order is defined by the order of the fields in the selection set. However, sorting definition documents will not cause any executional changes. Some lists of nodes will have a primary sort based on what makes sense, with the secondary sort being by name:

  • A definition document will have the schema first, directives second, and types third
  • A schema definition will have the query first, mutation second, and subscription defined third
  • Executable documents will have queries first, mutations second, subscriptions third, and fragments fourth
  • Selection sets will have fields first, inline fragments second, and fragment spreads third

@Shane32 Shane32 self-assigned this Jun 19, 2023
@github-actions github-actions bot added the test Pull request that adds new or changes existing tests label Jun 19, 2023
@Shane32 Shane32 added this to the 8.4 milestone Jun 19, 2023
@Shane32 Shane32 added enhancement New feature or request and removed test Pull request that adds new or changes existing tests labels Jun 19, 2023
@Shane32 Shane32 merged commit 51e77c1 into v8 Jun 24, 2023
@Shane32 Shane32 deleted the add_sorting branch June 24, 2023 17:34
Comment on lines +23 to +30
"f1 description"
f1: String

"f2 description"
f2: [[Float!]!]!

"f3 description"
f3: ID!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken indentation.

@sungam3r
Copy link
Member

reviewed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants