-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add extend schema (AST print) to SchemaPrinter #3471
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
Conversation
private boolean shouldPrintAsAst(SchemaDefinition definition) { | ||
return options.isUseAstDefinitions() && definition != null; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to type definition version above
} | ||
out.print('\n'); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
extend
extension definition). We had the methods in place inside the AST printer, this PR adds this to theSchemaPrinter
.