diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/helpers/Deprecated.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/helpers/Deprecated.kt index 9cb3583fd47..42771a54846 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/helpers/Deprecated.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/helpers/Deprecated.kt @@ -6,8 +6,6 @@ import com.squareup.kotlinpoet.AnnotationSpec internal fun deprecatedAnnotation(message: String) = AnnotationSpec .builder(KotlinSymbols.Deprecated) .apply { - if (message.isNotBlank()) { - addMember("message = %S", message) - } + addMember("message = %S", message) } .build() \ No newline at end of file diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql index 4d79b215fdf..88a5c6c7ee9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql @@ -4,5 +4,6 @@ query TestQuery($episode: Episode) { name deprecated deprecatedBool + deprecatedEmptyReason } } \ No newline at end of file diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/TestQuery.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/TestQuery.java.expected index 31d1c9af994..e9fd2e0ac67 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/TestQuery.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/TestQuery.java.expected @@ -28,7 +28,7 @@ import java.lang.SuppressWarnings; public class TestQuery implements Query { public static ExecutableDefinition definition = new Definition(); - public static final String OPERATION_ID = "6a8dd101c1681dc829d72040868fdf394c52bacb692da3549bc73e9504013470"; + public static final String OPERATION_ID = "966ff95da151b6e5de110e4ef356053da71e83ed39055254fefec22b9c8e15e4"; /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -39,10 +39,11 @@ public class TestQuery implements Query { * name * deprecated * deprecatedBool + * deprecatedEmptyReason * } * } */ - public static final String OPERATION_DOCUMENT = "query TestQuery($episode: Episode) { hero(episode: $episode) { name deprecated deprecatedBool } }"; + public static final String OPERATION_DOCUMENT = "query TestQuery($episode: Episode) { hero(episode: $episode) { name deprecated deprecatedBool deprecatedEmptyReason } }"; public static final String OPERATION_NAME = "TestQuery"; @@ -229,16 +230,24 @@ public class TestQuery implements Query { @Deprecated public Boolean deprecatedBool; + /** + * + */ + @Deprecated + public String deprecatedEmptyReason; + private transient volatile int $hashCode; private transient volatile boolean $hashCodeMemoized; private transient volatile String $toString; - public Hero(String name, String deprecated, Boolean deprecatedBool) { + public Hero(String name, String deprecated, Boolean deprecatedBool, + String deprecatedEmptyReason) { this.name = name; this.deprecated = deprecated; this.deprecatedBool = deprecatedBool; + this.deprecatedEmptyReason = deprecatedEmptyReason; } @Override @@ -250,7 +259,8 @@ public class TestQuery implements Query { Hero that = (Hero) o; return ((this.name == null) ? (that.name == null) : this.name.equals(that.name)) &&((this.deprecated == null) ? (that.deprecated == null) : this.deprecated.equals(that.deprecated)) - &&((this.deprecatedBool == null) ? (that.deprecatedBool == null) : this.deprecatedBool.equals(that.deprecatedBool)); + &&((this.deprecatedBool == null) ? (that.deprecatedBool == null) : this.deprecatedBool.equals(that.deprecatedBool)) + &&((this.deprecatedEmptyReason == null) ? (that.deprecatedEmptyReason == null) : this.deprecatedEmptyReason.equals(that.deprecatedEmptyReason)); } return false; } @@ -265,6 +275,8 @@ public class TestQuery implements Query { __h ^= (deprecated == null) ? 0 : deprecated.hashCode(); __h *= 1000003; __h ^= (deprecatedBool == null) ? 0 : deprecatedBool.hashCode(); + __h *= 1000003; + __h ^= (deprecatedEmptyReason == null) ? 0 : deprecatedEmptyReason.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } @@ -277,7 +289,8 @@ public class TestQuery implements Query { $toString = "Hero{" + "name=" + name + ", " + "deprecated=" + deprecated + ", " - + "deprecatedBool=" + deprecatedBool + + "deprecatedBool=" + deprecatedBool + ", " + + "deprecatedEmptyReason=" + deprecatedEmptyReason + "}"; } return $toString; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/adapter/TestQuery_ResponseAdapter.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/adapter/TestQuery_ResponseAdapter.java.expected index 590f107c5c1..75eefdd2f22 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/adapter/TestQuery_ResponseAdapter.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/adapter/TestQuery_ResponseAdapter.java.expected @@ -58,7 +58,7 @@ public class TestQuery_ResponseAdapter { public enum Hero implements Adapter { INSTANCE; - private static final List RESPONSE_NAMES = Arrays.asList("name", "deprecated", "deprecatedBool"); + private static final List RESPONSE_NAMES = Arrays.asList("name", "deprecated", "deprecatedBool", "deprecatedEmptyReason"); @SuppressWarnings("unchecked") @Override @@ -67,6 +67,7 @@ public class TestQuery_ResponseAdapter { String _name = null; String _deprecated = null; Boolean _deprecatedBool = null; + String _deprecatedEmptyReason = null; loop: while(true) { @@ -74,6 +75,7 @@ public class TestQuery_ResponseAdapter { case 0: _name = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; case 1: _deprecated = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; case 2: _deprecatedBool = Adapters.BooleanAdapter.fromJson(reader, customScalarAdapters); break; + case 3: _deprecatedEmptyReason = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; default: break loop; } } @@ -81,11 +83,13 @@ public class TestQuery_ResponseAdapter { Assertions.checkFieldNotMissing(_name, "name"); Assertions.checkFieldNotMissing(_deprecated, "deprecated"); Assertions.checkFieldNotMissing(_deprecatedBool, "deprecatedBool"); + Assertions.checkFieldNotMissing(_deprecatedEmptyReason, "deprecatedEmptyReason"); return new TestQuery.Hero( _name, _deprecated, - _deprecatedBool + _deprecatedBool, + _deprecatedEmptyReason ); } @@ -100,6 +104,9 @@ public class TestQuery_ResponseAdapter { writer.name("deprecatedBool"); Adapters.BooleanAdapter.toJson(writer, customScalarAdapters, value.deprecatedBool); + + writer.name("deprecatedEmptyReason"); + Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.deprecatedEmptyReason); } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/selections/TestQuerySelections.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/selections/TestQuerySelections.java.expected index 542f38c2b0f..567841c52c8 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/selections/TestQuerySelections.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/selections/TestQuerySelections.java.expected @@ -23,7 +23,8 @@ public class TestQuerySelections { private static List __hero = Arrays.asList( new CompiledField.Builder("name", new CompiledNotNullType(GraphQLString.type)).build(), new CompiledField.Builder("deprecated", new CompiledNotNullType(GraphQLString.type)).build(), - new CompiledField.Builder("deprecatedBool", new CompiledNotNullType(GraphQLBoolean.type)).build() + new CompiledField.Builder("deprecatedBool", new CompiledNotNullType(GraphQLBoolean.type)).build(), + new CompiledField.Builder("deprecatedEmptyReason", new CompiledNotNullType(GraphQLString.type)).build() ); public static List __root = Arrays.asList( diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/TestQuery.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/TestQuery.kt.expected index 5622371d5bf..d201b79f5fb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/TestQuery.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/TestQuery.kt.expected @@ -54,6 +54,8 @@ public data class TestQuery( public val deprecated: String, @Deprecated(message = "No longer supported") public val deprecatedBool: Boolean, + @Deprecated(message = "") + public val deprecatedEmptyReason: String, ) } @@ -68,7 +70,7 @@ public data class TestQuery( .build() public const val OPERATION_ID: String = - "6a8dd101c1681dc829d72040868fdf394c52bacb692da3549bc73e9504013470" + "966ff95da151b6e5de110e4ef356053da71e83ed39055254fefec22b9c8e15e4" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -80,12 +82,13 @@ public data class TestQuery( * name * deprecated * deprecatedBool + * deprecatedEmptyReason * } * } * ``` */ public val OPERATION_DOCUMENT: String - get() = "query TestQuery(${'$'}episode: Episode) { hero(episode: ${'$'}episode) { name deprecated deprecatedBool } }" + get() = "query TestQuery(${'$'}episode: Episode) { hero(episode: ${'$'}episode) { name deprecated deprecatedBool deprecatedEmptyReason } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/adapter/TestQuery_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/adapter/TestQuery_ResponseAdapter.kt.expected index c466aa7454a..b032835493f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/adapter/TestQuery_ResponseAdapter.kt.expected @@ -49,18 +49,21 @@ public object TestQuery_ResponseAdapter { } private object Hero : Adapter { - public val RESPONSE_NAMES: List = listOf("name", "deprecated", "deprecatedBool") + public val RESPONSE_NAMES: List = + listOf("name", "deprecated", "deprecatedBool", "deprecatedEmptyReason") override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Hero { var _name: String? = null var _deprecated: String? = null var _deprecatedBool: Boolean? = null + var _deprecatedEmptyReason: String? = null while (true) { when (reader.selectName(RESPONSE_NAMES)) { 0 -> _name = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> _deprecated = StringAdapter.fromJson(reader, customScalarAdapters) 2 -> _deprecatedBool = BooleanAdapter.fromJson(reader, customScalarAdapters) + 3 -> _deprecatedEmptyReason = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } @@ -68,7 +71,8 @@ public object TestQuery_ResponseAdapter { return TestQuery.Data.Hero( name = _name ?: missingField(reader, "name"), deprecated = _deprecated ?: missingField(reader, "deprecated"), - deprecatedBool = _deprecatedBool ?: missingField(reader, "deprecatedBool") + deprecatedBool = _deprecatedBool ?: missingField(reader, "deprecatedBool"), + deprecatedEmptyReason = _deprecatedEmptyReason ?: missingField(reader, "deprecatedEmptyReason") ) } @@ -86,6 +90,9 @@ public object TestQuery_ResponseAdapter { writer.name("deprecatedBool") BooleanAdapter.toJson(writer, customScalarAdapters, value.deprecatedBool) + + writer.name("deprecatedEmptyReason") + StringAdapter.toJson(writer, customScalarAdapters, value.deprecatedEmptyReason) } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/selections/TestQuerySelections.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/selections/TestQuerySelections.kt.expected index 86b5d6069e5..9e38afe3f39 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/selections/TestQuerySelections.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/selections/TestQuerySelections.kt.expected @@ -29,6 +29,10 @@ public object TestQuerySelections { CompiledField.Builder( name = "deprecatedBool", type = GraphQLBoolean.type.notNull() + ).build(), + CompiledField.Builder( + name = "deprecatedEmptyReason", + type = GraphQLString.type.notNull() ).build() ) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/schema.graphqls b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/schema.graphqls index 7ce813a3e49..bce19d55f44 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/schema.graphqls +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/schema.graphqls @@ -10,4 +10,5 @@ type Character { name: String! deprecated: String! @deprecated deprecatedBool: Boolean! @deprecated + deprecatedEmptyReason: String! @deprecated(reason: "") } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index 9eadac9b18d..9daf722d5c2 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/measurements +++ b/libraries/apollo-compiler/src/test/graphql/com/example/measurements @@ -2,11 +2,11 @@ // If you updated the codegen and test fixtures, you should commit this file too. Test: Total LOC: -aggregate-all 200014 -aggregate-kotlin-responseBased 62779 +aggregate-all 200049 +aggregate-kotlin-responseBased 62793 aggregate-kotlin-operationBased 41065 aggregate-kotlin-compat 0 -aggregate-java-operationBased 96170 +aggregate-java-operationBased 96191 java-operationBased-fragments_with_defer_and_include_directives 5747 kotlin-operationBased-fragments_with_defer_and_include_directives 3409 @@ -133,13 +133,13 @@ kotlin-operationBased-fragment_spread_with_nested_fields java-operationBased-monomorphic 648 java-operationBased-interface_always_nested 644 kotlin-responseBased-union_fragment 641 +java-operationBased-deprecation 639 kotlin-responseBased-used_arguments 639 java-operationBased-capitalized_fields 626 java-operationBased-field_with_include_directive 625 java-operationBased-hero_with_review 625 kotlin-operationBased-operationbased2_ex8 625 java-operationBased-recursive_selection 622 -java-operationBased-deprecation 618 kotlin-operationBased-union_fragment 607 kotlin-responseBased-java_android_annotations 606 kotlin-responseBased-java_apollo_optionals 606 @@ -205,9 +205,9 @@ kotlin-operationBased-typename_always_first java-operationBased-merged_include 451 java-operationBased-operation_id_generator 451 kotlin-operationBased-path_vs_flat_accessors 448 +kotlin-responseBased-deprecation 444 kotlin-responseBased-hero_name 441 kotlin-responseBased-interface_always_nested 432 -kotlin-responseBased-deprecation 430 kotlin-responseBased-enum_field 430 kotlin-operationBased-root_query_fragment 424 kotlin-responseBased-inline_fragment_for_non_optional_field 423