Add extend schema (AST print) to SchemaPrinter#3471
Conversation
| private boolean shouldPrintAsAst(SchemaDefinition definition) { | ||
| return options.isUseAstDefinitions() && definition != null; | ||
| } | ||
|
|
There was a problem hiding this comment.
Similar to type definition version above
| } | ||
| out.print('\n'); | ||
| } | ||
|
|
There was a problem hiding this comment.
Similar to type definition version above. This prints everything including directives and description.
| if (subscriptionType != null) { | ||
| out.format(" subscription: %s\n", subscriptionType.getName()); | ||
| if (shouldPrintAsAst(schema.getDefinition())) { | ||
| printAsAst(out, schema.getDefinition(), schema.getExtensionDefinitions()); |
There was a problem hiding this comment.
Main change on this line: if AST flag is on, use the new AST print method for SchemaDefinition
| out.format(" subscription: %s\n", subscriptionType.getName()); | ||
| if (shouldPrintAsAst(schema.getDefinition())) { | ||
| printAsAst(out, schema.getDefinition(), schema.getExtensionDefinitions()); | ||
| } else { |
There was a problem hiding this comment.
What follows is the original code, this will run if AST switch is off
|
|
||
| extend schema @schemaDirective { | ||
| query: MyQuery | ||
| } |
There was a problem hiding this comment.
Note: although there is an implicit schema block if it is not specified, if you want to extend schema you MUST also have an explicit schema block defined in the schema.
| ''' | ||
| } | ||
|
|
||
| def "will not print extend schema block when AST printing not enabled"() { |
There was a problem hiding this comment.
If AST switch is off, all extend definitions are combined.
This PR enables schema extension printing, reported in #3428.
This PR adds AST printing (which is the only way to get at the
extendextension definition). We had the methods in place inside the AST printer, this PR adds this to theSchemaPrinter.