-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Changes in schema directive printing AND the comment formats #1609
Changes in schema directive printing AND the comment formats #1609
Conversation
…ent formats used
@@ -62,17 +62,27 @@ | |||
|
|||
static { |
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.
Unrelated comment.
Is there a reason for this to be in a static block versus just building it directly into the static variable using the builder, for example:
static final DirectiveDefinition DEPRECATED_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition().name("deprecated")
.directiveLocation(createLocation(DirectiveLocation.FIELD_DEFINITION))
...
.inputValueDefinition(...)
.build();
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.
yeah not sure - looks like it could have been a chained builder call.
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.
done
@@ -113,6 +115,24 @@ class SchemaPrinterTest extends Specification { | |||
argStr == "(arg1: [Int!] = 10, arg2: String, arg3: String = \"default\")" | |||
} | |||
|
|||
def "argsString_comments"() { | |||
def argument1 = new GraphQLArgument("arg1", "A multiline\ncomment", list(nonNull(Scalars.GraphQLInt)), 10) |
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.
Do we support new line characters for window systems? \r\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.
Nominally yes - but we build and dev on Mac / Linux only. That is we dont run the tests on Windows per se.
I have forgotten my \n
rules on Windows but for some reason I recall it working as expected in many circumstances
out.format(" %s%s\n", enumValueDefinition.getName(), directivesString(GraphQLEnumValueDefinition.class, enumValueDefinition.getDirectives())); | ||
List<GraphQLDirective> enumValueDirectives = enumValueDefinition.getDirectives(); | ||
if (enumValueDefinition.isDeprecated()) { | ||
enumValueDirectives = addDeprecatedDirectiveIfNeeded(enumValueDirectives); |
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.
I see you have this private method to help adding the deprecated directive to the list if it does not exist. Is there a reason why this is a list instead of a set in which case this private method wouldn't be needed.
@@ -458,7 +511,7 @@ private static String printAst(Object value, GraphQLInputType type) { | |||
|
|||
// when serializing a GraphQL schema using the type system language, a | |||
// schema definition should be omitted if only uses the default root type names. | |||
boolean needsSchemaPrinted = options.includeSchemaDefinition; | |||
boolean needsSchemaPrinted = options.isIncludeSchemaDefinition(); |
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.
Any reason for adding the is
at the start, seems to flow easier without it.
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.
one was a field - this is now the public method. Not sure why I changed it. Consistency elsewhere?? Not sure
private boolean hasDeprecatedDirective(List<GraphQLDirective> directives) { | ||
return directives.stream() | ||
.filter(this::isDeprecatedDirective) | ||
.count() == 1; |
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.
Considering this is a list and not a set, can we ever have count > 1
, in which case should this be count() >= 1
to work for all these scenarios? Or have we built enough invariants for this class that this shouldn't happen?
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.
Hmm good point - the rest of the code base puts List<GraphQLDirective>
everywhere and hence its influenced this code as well
I think other parts of the code stop multiple named directives
} | ||
|
||
private AstDescriptionAndComments getDescriptionAndComments(Object descriptionHolder) { | ||
private String getDescription(Object descriptionHolder) { |
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.
Can this be a static function? does it need references to this?
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.
could be - but almost no other method is static in this class - so its consistent in that regard
Co-Authored-By: Jaiden Ashmore <jaidenkyleashmore@gmail.com>
Co-Authored-By: Jaiden Ashmore <jaidenkyleashmore@gmail.com>
Co-Authored-By: Jaiden Ashmore <jaidenkyleashmore@gmail.com>
See #1587
Will now ONLY show descriptions (and never captured comments other than ones turned into descriptions by SchemaGen