-
Notifications
You must be signed in to change notification settings - Fork 100
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
Support @deprecated directives without a reason attribute #711
base: master
Are you sure you want to change the base?
Support @deprecated directives without a reason attribute #711
Conversation
@@ -2780,23 +2780,37 @@ class KotlinCodeGenTest { | |||
} | |||
|
|||
@Test | |||
fun deprecateAnnotationWithNoMesssage() { | |||
fun deprecateAnnotationWithNoReason() { |
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.
Nit: since we're changing it anyway, can we change it to be correct (there is a reason in this test case).
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 will make it correct by removing the reason attribute so that its missing from both deprecated directives. And for consistency, I will also update the corresponding test in CodeGenTest to test for the same scenario.
@@ -46,7 +46,7 @@ fun applyDirectivesKotlin(directives: List<Directive>, config: CodeGenConfig): M | |||
if (argumentMap.containsKey(ParserConstants.REASON)) { | |||
annotations.add(deprecatedAnnotation((argumentMap[ParserConstants.REASON] as StringValue).value)) | |||
} else { | |||
throw IllegalArgumentException("Deprecated requires an argument `${ParserConstants.REASON}`") | |||
annotations.add(deprecatedAnnotation("Deprecated.")) |
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 think a String like "Deprecated in GraphQL schema" might be a bit better.
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.
PR updated.
This PR changes how the code generator handle schema
@deprecated
directives that are missing thereason
attribute. The existing behavior was to throw an exception, which results in broken builds. The new behavior is to default to an empty comment when generating Java code and to default to a "Deprecated." message when generating Kotlin@deprecated
annotations.