Rewrite SchemaPrinter
Convert Schema into GraphQLDocument and then use SDLWriter.
Note: why SchemaPrinter sorts types and directives first?
https://github.com/graphql-dotnet/graphql-dotnet/blob/master/src/GraphQL/Utilities/SchemaPrinter.cs#L90
https://github.com/graphql-dotnet/graphql-dotnet/blob/master/src/GraphQL/Utilities/SchemaPrinter.cs#L95
And after SchemaPrinter applies comparers:
https://github.com/graphql-dotnet/graphql-dotnet/blob/master/src/GraphQL/Utilities/SchemaPrinter.cs#L102
https://github.com/graphql-dotnet/graphql-dotnet/blob/master/src/GraphQL/Utilities/SchemaPrinter.cs#L103
😕
Looks like a bug because output is sorted by names even if Options.Comparer is null.
Note 2: SchemaPrinter adds whitespace after # in each comment. See prints_enum test for example. Looks like a bug too.
I think there should be some logic to the default behavior. Perhaps just types and directives. Perhaps all "sortable" members. I feel that 'no sorting' would be a bad choice. Perhaps setting the comparer to null allows for "no sorting", but I feel that it should sort by default.
SchemaPrinter won't print comments anymore, correct? Since a Schema can't contain comments, and descriptions will be printed as descriptions, not comments.
SchemaPrinter won't print comments anymore, correct? Since a Schema can't contain comments, and descriptions will be printed as descriptions, not comments.
Yes.
See also:
- #2887
It looks like now I should finish this one for v8 🤔
Convert
SchemaintoGraphQLDocumentand then useSDLWriter.
Completed in
- #3649