graphql-dotnet icon indicating copy to clipboard operation
graphql-dotnet copied to clipboard

Rewrite SchemaPrinter

Open sungam3r opened this issue 3 years ago • 5 comments

Convert Schema into GraphQLDocument and then use SDLWriter.

sungam3r avatar Jan 19 '22 23:01 sungam3r

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.

sungam3r avatar Jan 29 '22 00:01 sungam3r

Note 2: SchemaPrinter adds whitespace after # in each comment. See prints_enum test for example. Looks like a bug too.

sungam3r avatar Jan 29 '22 17:01 sungam3r

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.

Shane32 avatar Jan 30 '22 16:01 Shane32

SchemaPrinter won't print comments anymore, correct? Since a Schema can't contain comments, and descriptions will be printed as descriptions, not comments.

Shane32 avatar Jan 30 '22 16:01 Shane32

SchemaPrinter won't print comments anymore, correct? Since a Schema can't contain comments, and descriptions will be printed as descriptions, not comments.

Yes.

sungam3r avatar Jan 30 '22 16:01 sungam3r

See also:

  • #2887

Shane32 avatar Apr 24 '23 01:04 Shane32

It looks like now I should finish this one for v8 🤔

sungam3r avatar Apr 25 '23 16:04 sungam3r

Convert Schema into GraphQLDocument and then use SDLWriter.

Completed in

  • #3649

Shane32 avatar Sep 17 '23 03:09 Shane32