From c4e09d414b37ee60730b1505b7ec318dcbcca321 Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 16:01:36 +0200 Subject: [PATCH 01/11] Add a null-check to java enum safeValueOf --- .../compiler/codegen/java/JavaClassNames.kt | 1 + .../codegen/java/schema/EnumAsClassBuilder.kt | 6 +++--- .../codegen/java/schema/EnumAsEnumBuilder.kt | 2 +- tests/enums/src/test/kotlin/test/EnumsTest.kt | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaClassNames.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaClassNames.kt index 4d434de3583..866ecd61f3c 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaClassNames.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaClassNames.kt @@ -111,6 +111,7 @@ internal object JavaClassNames { val Map: ClassName = ClassName.get("java.util", "Map") val MapOfStringToObject = ParameterizedTypeName.get(Map, String, Object) val JavaOptional = ClassName.get("java.util", "Optional") + val Objects = ClassName.get("java.util", "Objects") val ObjectBuilderKt = ClassName.get(apolloApiPackageName, "ObjectBuilderKt") val ObjectMap = ClassName.get(apolloApiPackageName, "ObjectMap") diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt index a76d0426841..8a3546f94f1 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt @@ -63,7 +63,7 @@ internal class EnumAsClassBuilder( ) .addMethod( MethodSpec.constructorBuilder() - .addModifiers(Modifier.PUBLIC) + .addModifiers(Modifier.PRIVATE) .addParameter(ParameterSpec.builder(JavaClassNames.String, rawValue).build()) .addCode("this.$rawValue = $rawValue;\n") .build() @@ -86,7 +86,7 @@ internal class EnumAsClassBuilder( .returns(selfClassName) .addCode( CodeBlock.builder() - .beginControlFlow("switch($rawValue)") + .beginControlFlow("switch ($T.requireNonNull($rawValue))", JavaClassNames.Objects) .apply { values.forEach { add("case $S: return $T.$L;\n", it.name, selfClassName, it.targetName.escapeTypeReservedWord() @@ -113,7 +113,7 @@ internal class EnumAsClassBuilder( .addJavadoc(L, "An enum value that wasn't known at compile time.\n") .addMethod( MethodSpec.constructorBuilder() - .addModifiers(Modifier.PUBLIC) + .addModifiers(Modifier.PRIVATE) .addParameter(ParameterSpec.builder(JavaClassNames.String, rawValue).build()) .addCode("super($rawValue);\n") .build() diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt index 271b7e3d462..ee75eb7a9d3 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt @@ -85,7 +85,7 @@ internal class EnumAsEnumBuilder( .returns(selfClassName) .addCode( CodeBlock.builder() - .beginControlFlow("switch ($rawValue)") + .beginControlFlow("switch ($T.requireNonNull($rawValue))", JavaClassNames.Objects) .apply { values.forEach { add("case $S: return $T.$L;\n", it.name, selfClassName, it.targetName.escapeTypeReservedWord() diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index 4b5606d5647..49d5a96d8e0 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -1,5 +1,6 @@ package test +import com.apollographql.apollo3.annotations.ApolloEnumConstructor import enums.kotlin15.type.Direction import enums.kotlin15.type.Foo import enums.kotlin15.type.FooEnum @@ -7,6 +8,9 @@ import enums.kotlin15.type.FooSealed import enums.kotlin15.type.Gravity import org.junit.Test import kotlin.test.assertEquals +import kotlin.test.assertFails +import kotlin.test.assertIs +import kotlin.test.assertNotEquals class EnumsTest { @Test @@ -31,7 +35,7 @@ class EnumsTest { assertEquals(Gravity.TOP, Gravity.safeValueOf("TOP")) @Suppress("DEPRECATION") assertEquals(Gravity.top2, Gravity.safeValueOf("top2")) - assertEquals(Gravity.UNKNOWN__("newGravity"), Gravity.safeValueOf("newGravity")) + assertEquals(@OptIn(ApolloEnumConstructor::class) Gravity.UNKNOWN__("newGravity"), Gravity.safeValueOf("newGravity")) assertEquals(Gravity.name, Gravity.safeValueOf("name")) assertEquals(Gravity.ordinal, Gravity.safeValueOf("ordinal")) assertEquals(Gravity.type__, Gravity.safeValueOf("type")) @@ -48,6 +52,11 @@ class EnumsTest { assertEquals(enums.java.type.Direction.ordinal, enums.java.type.Direction.safeValueOf("ordinal")) assertEquals(enums.java.type.Direction.type__, enums.java.type.Direction.safeValueOf("type")) assertEquals(enums.java.type.Direction.Companion, enums.java.type.Direction.safeValueOf("Companion")) + assertIs( + assertFails { + enums.java.type.Direction.safeValueOf(null) + } + ) } @Test @@ -59,6 +68,11 @@ class EnumsTest { assertEquals(enums.java.type.Gravity.ordinal, enums.java.type.Gravity.safeValueOf("ordinal")) assertEquals(enums.java.type.Gravity.type__, enums.java.type.Gravity.safeValueOf("type")) assertEquals(enums.java.type.Gravity.Companion, enums.java.type.Gravity.safeValueOf("Companion")) + assertIs( + assertFails { + enums.java.type.Gravity.safeValueOf(null) + } + ) } From af2e53df3f5baea5d49258e885266958515e4860 Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 16:02:28 +0200 Subject: [PATCH 02/11] Make java enum as class' equals and hashcode call super --- .../codegen/java/helpers/DataClass.kt | 236 ++++++++++-------- tests/enums/src/test/kotlin/test/EnumsTest.kt | 5 +- 2 files changed, 135 insertions(+), 106 deletions(-) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt index 3526af58279..618bbf0a06d 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt @@ -1,12 +1,13 @@ package com.apollographql.apollo3.compiler.codegen.java.helpers import com.apollographql.apollo3.compiler.GeneratedMethod -import com.apollographql.apollo3.compiler.GeneratedMethod.* -import com.apollographql.apollo3.compiler.internal.applyIf +import com.apollographql.apollo3.compiler.GeneratedMethod.EQUALS_HASH_CODE +import com.apollographql.apollo3.compiler.GeneratedMethod.TO_STRING import com.apollographql.apollo3.compiler.codegen.Identifier.__h import com.apollographql.apollo3.compiler.codegen.java.JavaClassNames import com.apollographql.apollo3.compiler.codegen.java.L import com.apollographql.apollo3.compiler.codegen.java.joinToCode +import com.apollographql.apollo3.compiler.internal.applyIf import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec @@ -29,8 +30,8 @@ import javax.lang.model.element.Modifier internal fun TypeSpec.Builder.makeClassFromParameters( generateMethods: List, parameters: List, - className: ClassName - ): TypeSpec.Builder { + className: ClassName, +): TypeSpec.Builder { addMethod( MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) @@ -55,7 +56,7 @@ internal fun TypeSpec.Builder.makeClassFromParameters( internal fun TypeSpec.Builder.addGeneratedMethods( className: ClassName, - generateMethods: List = listOf(EQUALS_HASH_CODE, TO_STRING) + generateMethods: List = listOf(EQUALS_HASH_CODE, TO_STRING), ): TypeSpec.Builder { return applyIf(generateMethods.contains(EQUALS_HASH_CODE)) { withEqualsImplementation(className) } .applyIf(generateMethods.contains(EQUALS_HASH_CODE)) { withHashCodeImplementation() } @@ -68,8 +69,8 @@ internal fun TypeSpec.Builder.addGeneratedMethods( internal fun TypeSpec.Builder.makeClassFromProperties( generateMethods: List, fields: List, - className: ClassName - ): TypeSpec.Builder { + className: ClassName, +): TypeSpec.Builder { addMethod( MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) @@ -94,42 +95,45 @@ internal fun TypeSpec.Builder.makeClassFromProperties( internal fun TypeSpec.Builder.withToStringImplementation(className: ClassName): TypeSpec.Builder { fun printFieldCode(fieldIndex: Int, fieldName: String) = - CodeBlock.builder() - .let { if (fieldIndex > 0) it.add(" + \", \"\n") else it.add("\n") } - .indent() - .add("+ \$S + \$L", "$fieldName=", fieldName) - .unindent() - .build() + CodeBlock.builder() + .let { if (fieldIndex > 0) it.add(" + \", \"\n") else it.add("\n") } + .indent() + .add("+ \$S + \$L", "$fieldName=", fieldName) + .unindent() + .build() fun methodCode() = - CodeBlock.builder() - .beginControlFlow("if (\$L == null)", MEMOIZED_TO_STRING_VAR) - .add("\$L = \$S", "\$toString", "${className.simpleName()}{") - .add(fieldSpecs - .filter { !it.hasModifier(Modifier.STATIC) } - .filter { !it.hasModifier(Modifier.TRANSIENT) } - .map { it.name } - .mapIndexed(::printFieldCode) - .fold(CodeBlock.builder(), CodeBlock.Builder::add) - .build()) - .add(CodeBlock.builder() - .indent() - .add("\n+ \$S;\n", "}") - .unindent() - .build()) - .endControlFlow() - .addStatement("return \$L", MEMOIZED_TO_STRING_VAR) - .build() + CodeBlock.builder() + .beginControlFlow("if (\$L == null)", MEMOIZED_TO_STRING_VAR) + .add("\$L = \$S", "\$toString", "${className.simpleName()}{") + .add(fieldSpecs + .filter { !it.hasModifier(Modifier.STATIC) } + .filter { !it.hasModifier(Modifier.TRANSIENT) } + .map { it.name } + .mapIndexed(::printFieldCode) + .fold(CodeBlock.builder(), CodeBlock.Builder::add) + .build()) + .add(CodeBlock.builder() + .indent() + .add("\n+ \$S;\n", "}") + .unindent() + .build() + ) + .endControlFlow() + .addStatement("return \$L", MEMOIZED_TO_STRING_VAR) + .build() - return addField(FieldSpec.builder(JavaClassNames.String, MEMOIZED_TO_STRING_VAR, Modifier.PRIVATE, Modifier.VOLATILE, - Modifier.TRANSIENT) - .build()) - .addMethod(MethodSpec.methodBuilder("toString") - .addAnnotation(JavaClassNames.Override) - .addModifiers(Modifier.PUBLIC) - .returns(JavaClassNames.String) - .addCode(methodCode()) - .build()) + return addField( + FieldSpec.builder(JavaClassNames.String, MEMOIZED_TO_STRING_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() + ) + .addMethod( + MethodSpec.methodBuilder("toString") + .addAnnotation(JavaClassNames.Override) + .addModifiers(Modifier.PUBLIC) + .returns(JavaClassNames.String) + .addCode(methodCode()) + .build() + ) } private fun List.equalsCode(): CodeBlock = filter { !it.hasModifier(Modifier.STATIC) } @@ -138,92 +142,114 @@ private fun List.equalsCode(): CodeBlock = filter { !it.hasModifier(M .joinToCode("\n &&") private fun FieldSpec.equalsCode() = - CodeBlock.builder() - .let { - if (type.isPrimitive) { - if (type == TypeName.DOUBLE) { - it.add("Double.doubleToLongBits(this.\$L) == Double.doubleToLongBits(that.\$L)", - name, name) - } else { - it.add("this.\$L == that.\$L", name, name) - } + CodeBlock.builder() + .let { + if (type.isPrimitive) { + if (type == TypeName.DOUBLE) { + it.add("Double.doubleToLongBits(this.\$L) == Double.doubleToLongBits(that.\$L)", name, name) } else { - it.add("((this.\$L == null) ? (that.\$L == null) : this.\$L.equals(that.\$L))", name, name, name, name) + it.add("this.\$L == that.\$L", name, name) } + } else { + it.add("((this.\$L == null) ? (that.\$L == null) : this.\$L.equals(that.\$L))", name, name, name, name) } - .build() + } + .build() internal fun TypeSpec.Builder.withEqualsImplementation(className: ClassName): TypeSpec.Builder { + val hasSuperClass = build().superclass != ClassName.OBJECT fun methodCode(typeJavaClass: ClassName) = - CodeBlock.builder() - .beginControlFlow("if (o == this)") - .addStatement("return true") - .endControlFlow() - .beginControlFlow("if (o instanceof \$T)", typeJavaClass) - .apply { - if (fieldSpecs.isEmpty()) { + CodeBlock.builder() + .beginControlFlow("if (o == this)") + .addStatement("return true") + .endControlFlow() + .beginControlFlow("if (o instanceof \$T)", typeJavaClass) + .apply { + if (fieldSpecs.isEmpty()) { + if (hasSuperClass) { + add("return super.equals(o);\n") + } else { add("return true;\n") + } + } else { + addStatement("\$T that = (\$T) o", typeJavaClass, typeJavaClass) + if (hasSuperClass) { + add("return super.equals(o) && $L;\n", fieldSpecs.equalsCode()) } else { - addStatement("\$T that = (\$T) o", typeJavaClass, typeJavaClass) - add("return $L;\n", if (fieldSpecs.isEmpty()) "true" else fieldSpecs.equalsCode()) + add("return $L;\n", fieldSpecs.equalsCode()) } } - .endControlFlow() - .addStatement("return false") - .build() + } + .endControlFlow() + .addStatement("return false") + .build() return addMethod(MethodSpec.methodBuilder("equals") - .addAnnotation(JavaClassNames.Override) - .addModifiers(Modifier.PUBLIC) - .returns(TypeName.BOOLEAN) - .addParameter(ParameterSpec.builder(TypeName.OBJECT, "o").build()) - .addCode(methodCode(className)) - .build()) + .addAnnotation(JavaClassNames.Override) + .addModifiers(Modifier.PUBLIC) + .returns(TypeName.BOOLEAN) + .addParameter(ParameterSpec.builder(TypeName.OBJECT, "o").build()) + .addCode(methodCode(className)) + .build() + ) } internal fun TypeSpec.Builder.withHashCodeImplementation(): TypeSpec.Builder { + val hasSuperClass = build().superclass != ClassName.OBJECT fun hashFieldCode(field: FieldSpec) = - CodeBlock.builder() - .addStatement("$__h *= 1000003") - .let { - if (field.type.isPrimitive) { - when (field.type.withoutAnnotations()) { - TypeName.DOUBLE -> it.addStatement("$__h ^= Double.valueOf(\$L).hashCode()", field.name) - TypeName.BOOLEAN -> it.addStatement("$__h ^= Boolean.valueOf(\$L).hashCode()", field.name) - else -> it.addStatement("$__h ^= \$L", field.name) - } - } else { - it.addStatement("$__h ^= (\$L == null) ? 0 : \$L.hashCode()", field.name, field.name) + CodeBlock.builder() + .addStatement("$__h *= 1000003") + .let { + if (field.type.isPrimitive) { + when (field.type.withoutAnnotations()) { + TypeName.DOUBLE -> it.addStatement("$__h ^= Double.valueOf(\$L).hashCode()", field.name) + TypeName.BOOLEAN -> it.addStatement("$__h ^= Boolean.valueOf(\$L).hashCode()", field.name) + else -> it.addStatement("$__h ^= \$L", field.name) } + } else { + it.addStatement("$__h ^= (\$L == null) ? 0 : \$L.hashCode()", field.name, field.name) } - .build() + } + .build() fun methodCode() = - CodeBlock.builder() - .beginControlFlow("if (!\$L)", MEMOIZED_HASH_CODE_FLAG_VAR) - .addStatement("int $__h = 1") - .add(fieldSpecs - .filter { !it.hasModifier(Modifier.STATIC) } - .filter { !it.hasModifier(Modifier.TRANSIENT) } - .map(::hashFieldCode) - .fold(CodeBlock.builder(), CodeBlock.Builder::add) - .build()) - .addStatement("\$L = $__h", MEMOIZED_HASH_CODE_VAR) - .addStatement("\$L = true", MEMOIZED_HASH_CODE_FLAG_VAR) - .endControlFlow() - .addStatement("return \$L", MEMOIZED_HASH_CODE_VAR) - .build() + CodeBlock.builder() + .beginControlFlow("if (!\$L)", MEMOIZED_HASH_CODE_FLAG_VAR) + .addStatement( + if (hasSuperClass) { + "int $__h = super.hashCode()" + } else { + "int $__h = 1" + } + ) + .add( + fieldSpecs + .filter { !it.hasModifier(Modifier.STATIC) } + .filter { !it.hasModifier(Modifier.TRANSIENT) } + .map(::hashFieldCode) + .fold(CodeBlock.builder(), CodeBlock.Builder::add) + .build() + ) + .addStatement("\$L = $__h", MEMOIZED_HASH_CODE_VAR) + .addStatement("\$L = true", MEMOIZED_HASH_CODE_FLAG_VAR) + .endControlFlow() + .addStatement("return \$L", MEMOIZED_HASH_CODE_VAR) + .build() - return addField(FieldSpec.builder(TypeName.INT, MEMOIZED_HASH_CODE_VAR, Modifier.PRIVATE, Modifier.VOLATILE, - Modifier.TRANSIENT).build()) - .addField(FieldSpec.builder(TypeName.BOOLEAN, MEMOIZED_HASH_CODE_FLAG_VAR, Modifier.PRIVATE, - Modifier.VOLATILE, Modifier.TRANSIENT).build()) - .addMethod(MethodSpec.methodBuilder("hashCode") - .addAnnotation(JavaClassNames.Override) - .addModifiers(Modifier.PUBLIC) - .returns(TypeName.INT) - .addCode(methodCode()) - .build()) + return addField( + FieldSpec.builder(TypeName.INT, MEMOIZED_HASH_CODE_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() + ) + .addField( + FieldSpec.builder(TypeName.BOOLEAN, MEMOIZED_HASH_CODE_FLAG_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() + ) + .addMethod( + MethodSpec.methodBuilder("hashCode") + .addAnnotation(JavaClassNames.Override) + .addModifiers(Modifier.PUBLIC) + .returns(TypeName.INT) + .addCode(methodCode()) + .build() + ) } diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index 49d5a96d8e0..3b6a64904f2 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -63,7 +63,10 @@ class EnumsTest { fun javaClasses() { assertEquals(enums.java.type.Gravity.TOP, enums.java.type.Gravity.safeValueOf("TOP")) assertEquals(enums.java.type.Gravity.top2, enums.java.type.Gravity.safeValueOf("top2")) - assertEquals(enums.java.type.Gravity.UNKNOWN__("newGravity"), enums.java.type.Gravity.safeValueOf("newGravity")) + val unknown = enums.java.type.Gravity.safeValueOf("newGravity") + assertEquals(enums.java.type.Gravity.UNKNOWN__::class.java, unknown::class.java) + assertEquals("newGravity", unknown.rawValue) + assertNotEquals(enums.java.type.Gravity.safeValueOf("newGravity2"), unknown) assertEquals(enums.java.type.Gravity.name, enums.java.type.Gravity.safeValueOf("name")) assertEquals(enums.java.type.Gravity.ordinal, enums.java.type.Gravity.safeValueOf("ordinal")) assertEquals(enums.java.type.Gravity.type__, enums.java.type.Gravity.safeValueOf("type")) From 4967fa4ed02bff6b8b2891ec4ec5287d76030266 Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 16:02:39 +0200 Subject: [PATCH 03/11] Update expected --- .../type/Enum.java.expected | 11 ++-- .../deprecation/type/Episode.java.expected | 11 ++-- .../enum_field/type/Gravity.java.expected | 11 ++-- .../enums_as_sealed/type/Enum.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../hero_details/type/hero_type.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Race.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/__TypeKind.java.expected | 11 ++-- .../type/AmenityCategory.java.expected | 11 ++-- .../src/test/graphql/com/example/measurements | 56 +++++++++---------- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../optional/type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Direction.java.expected | 11 ++-- .../type/renamedEnum.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- .../type/Episode.java.expected | 11 ++-- 27 files changed, 184 insertions(+), 158 deletions(-) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected index 592a99eba45..e65ec250511 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public class Enum { public static EnumType type = new EnumType("Enum", Arrays.asList("north", "North", "NORTH", "SOUTH")); @@ -25,13 +26,13 @@ public class Enum { public String rawValue; - public Enum(String rawValue) { + private Enum(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Enum safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "north": return Enum.north; case "North": return Enum.North; case "NORTH": return Enum.NORTH; @@ -50,7 +51,7 @@ public class Enum { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -60,7 +61,7 @@ public class Enum { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -68,7 +69,7 @@ public class Enum { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected index 0cc2efb3cb2..c75f866ec41 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public class Episode { public static EnumType type = new EnumType("Episode", Arrays.asList("JEDI", "CLONES")); @@ -21,13 +22,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "JEDI": return Episode.JEDI; case "CLONES": return Episode.CLONES; default: return new Episode.UNKNOWN__(rawValue); @@ -44,7 +45,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -54,7 +55,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -62,7 +63,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected index 94a08711858..86b121e2134 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public class Gravity { public static EnumType type = new EnumType("Gravity", Arrays.asList("TOP", "CENTER", "BOTTOM", "bottom", "is", "type", "String")); @@ -31,13 +32,13 @@ public class Gravity { public String rawValue; - public Gravity(String rawValue) { + private Gravity(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Gravity safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "TOP": return Gravity.TOP; case "CENTER": return Gravity.CENTER; case "BOTTOM": return Gravity.BOTTOM; @@ -59,7 +60,7 @@ public class Gravity { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -69,7 +70,7 @@ public class Gravity { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -77,7 +78,7 @@ public class Gravity { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected index 2321e89103f..703877b5d0a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public class Enum { public static EnumType type = new EnumType("Enum", Arrays.asList("north", "North", "NORTH", "SOUTH", "type")); @@ -27,13 +28,13 @@ public class Enum { public String rawValue; - public Enum(String rawValue) { + private Enum(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Enum safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "north": return Enum.north; case "North": return Enum.North; case "NORTH": return Enum.NORTH; @@ -53,7 +54,7 @@ public class Enum { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -63,7 +64,7 @@ public class Enum { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -71,7 +72,7 @@ public class Enum { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected index 5d61fe3e641..539442bbe5b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected index 16571bcd450..fc25ac250c5 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected @@ -10,6 +10,7 @@ import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Arrays; +import java.util.Objects; /** * Lower case enum type name @@ -23,12 +24,12 @@ public class Hero_type { public String rawValue; - public Hero_type(String rawValue) { + private Hero_type(String rawValue) { this.rawValue = rawValue; } public static Hero_type safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "human": return Hero_type.human; case "droid": return Hero_type.droid; default: return new Hero_type.UNKNOWN__(rawValue); @@ -45,7 +46,7 @@ public class Hero_type { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -55,7 +56,7 @@ public class Hero_type { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -63,7 +64,7 @@ public class Hero_type { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected index 04312b6bbcf..53079e6755b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected index cd08aef2eed..7bff54aa4d1 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected index 13348a416cd..e7b90d19be9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected @@ -10,6 +10,7 @@ import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Arrays; +import java.util.Objects; public class Race { public static EnumType type = new EnumType("Race", Arrays.asList("WOOKIE", "GUMGAN", "EWOK")); @@ -22,12 +23,12 @@ public class Race { public String rawValue; - public Race(String rawValue) { + private Race(String rawValue) { this.rawValue = rawValue; } public static Race safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "WOOKIE": return Race.WOOKIE; case "GUMGAN": return Race.GUMGAN; case "EWOK": return Race.EWOK; @@ -45,7 +46,7 @@ public class Race { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -55,7 +56,7 @@ public class Race { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -63,7 +64,7 @@ public class Race { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected index 991bc84fa25..2cd7a54063b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected index c6e1444bffa..43f0190820b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected index 477d9f801c1..db2ba61d655 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected index 8c84fedd899..f3f7d4ded91 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected index c6392bb2f14..b039efd0f1c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected @@ -10,6 +10,7 @@ import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Arrays; +import java.util.Objects; public class __TypeKind { public static EnumType type = new EnumType("__TypeKind", Arrays.asList("SCALAR", "OBJECT", "INTERFACE", "UNION", "ENUM", "INPUT_OBJECT", "LIST", "NON_NULL")); @@ -32,12 +33,12 @@ public class __TypeKind { public String rawValue; - public __TypeKind(String rawValue) { + private __TypeKind(String rawValue) { this.rawValue = rawValue; } public static __TypeKind safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "SCALAR": return __TypeKind.SCALAR; case "OBJECT": return __TypeKind.OBJECT; case "INTERFACE": return __TypeKind.INTERFACE; @@ -60,7 +61,7 @@ public class __TypeKind { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -70,7 +71,7 @@ public class __TypeKind { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -78,7 +79,7 @@ public class __TypeKind { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected index ab6ab52e2ce..dd68860e930 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected @@ -10,6 +10,7 @@ import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Arrays; +import java.util.Objects; public class AmenityCategory { public static EnumType type = new EnumType("AmenityCategory", Arrays.asList("Category0", "Category1")); @@ -20,12 +21,12 @@ public class AmenityCategory { public String rawValue; - public AmenityCategory(String rawValue) { + private AmenityCategory(String rawValue) { this.rawValue = rawValue; } public static AmenityCategory safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "Category0": return AmenityCategory.Category0; case "Category1": return AmenityCategory.Category1; default: return new AmenityCategory.UNKNOWN__(rawValue); @@ -42,7 +43,7 @@ public class AmenityCategory { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -52,7 +53,7 @@ public class AmenityCategory { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -60,7 +61,7 @@ public class AmenityCategory { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index 546fb3d603f..61ba36b9760 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/measurements +++ b/libraries/apollo-compiler/src/test/graphql/com/example/measurements @@ -2,28 +2,28 @@ // If you updated the codegen and test fixtures, you should commit this file too. Test: Total LOC: -aggregate-all 204879 +aggregate-all 204905 aggregate-kotlin-responseBased 65795 aggregate-kotlin-operationBased 42408 aggregate-kotlin-compat 0 -aggregate-java-operationBased 96676 +aggregate-java-operationBased 96702 java-operationBased-fragments_with_defer_and_include_directives 5600 kotlin-operationBased-fragments_with_defer_and_include_directives 3488 java-operationBased-data_builders 3031 -java-operationBased-mutation_create_review 2435 +java-operationBased-mutation_create_review 2436 kotlin-responseBased-fragment_with_inline_fragment 2422 kotlin-responseBased-data_builders 2355 -java-operationBased-fragment_with_inline_fragment 2261 +java-operationBased-fragment_with_inline_fragment 2262 kotlin-operationBased-data_builders 2004 java-operationBased-nested_named_fragments 1910 java-operationBased-fragment_spread_with_include_directive 1667 -java-operationBased-union_inline_fragments 1666 +java-operationBased-union_inline_fragments 1667 +java-operationBased-unique_type_name 1644 kotlin-responseBased-nested_named_fragments 1643 -java-operationBased-unique_type_name 1643 -java-operationBased-inline_fragment_intersection 1637 -java-operationBased-input_object_type 1625 -java-operationBased-mutation_create_review_semantic_naming 1609 +java-operationBased-inline_fragment_intersection 1638 +java-operationBased-input_object_type 1626 +java-operationBased-mutation_create_review_semantic_naming 1610 java-operationBased-root_query_fragment_with_nested_fragments 1607 java-operationBased-simple_fragment 1505 java-operationBased-named_fragment_delegate 1493 @@ -31,7 +31,7 @@ kotlin-responseBased-mutation_create_review java-operationBased-named_fragment_with_variables 1405 kotlin-responseBased-named_fragment_delegate 1371 kotlin-responseBased-unique_type_name 1354 -java-operationBased-nested_conditional_inline 1344 +java-operationBased-nested_conditional_inline 1345 java-operationBased-fragment_used_twice 1305 kotlin-operationBased-fragment_with_inline_fragment 1297 java-operationBased-multiple_fragments 1294 @@ -43,9 +43,9 @@ kotlin-responseBased-inline_fragment_intersection java-operationBased-two_heroes_with_friends 1241 java-operationBased-inline_fragment_merge_fields 1229 kotlin-responseBased-simple_fragment 1195 -java-operationBased-named_fragment_inside_inline_fragment 1186 +java-operationBased-named_fragment_inside_inline_fragment 1187 java-operationBased-fragments_with_type_condition 1183 -java-operationBased-target_name 1168 +java-operationBased-target_name 1169 kotlin-responseBased-fragment_used_twice 1157 kotlin-operationBased-inline_fragment_intersection 1154 java-operationBased-java_jetbrains_annotations 1154 @@ -56,7 +56,7 @@ kotlin-responseBased-union_inline_fragments java-operationBased-java_guava_optionals 1135 java-operationBased-java_java_optionals 1135 java-operationBased-java_apollo_optionals 1134 -java-operationBased-root_query_inline_fragment 1122 +java-operationBased-root_query_inline_fragment 1123 kotlin-operationBased-fragment_spread_with_include_directive 1121 kotlin-operationBased-unique_type_name 1109 kotlin-responseBased-fragments_with_type_condition 1102 @@ -66,7 +66,7 @@ kotlin-responseBased-multiple_fragments kotlin-responseBased-named_fragment_with_variables 1067 java-operationBased-simple_fragment_with_inline_fragments 1066 kotlin-operationBased-root_query_fragment_with_nested_fragments 1065 -java-operationBased-inline_fragments_with_friends 1056 +java-operationBased-inline_fragments_with_friends 1057 java-operationBased-fragment_spread_with_nested_fields 1054 kotlin-responseBased-simple_fragment_with_inline_fragments 1052 kotlin-operationBased-simple_fragment 1043 @@ -79,14 +79,14 @@ kotlin-responseBased-operationbased2_ex8 java-operationBased-deprecated_merged_field 950 kotlin-operationBased-nested_conditional_inline 948 java-operationBased-input_object_oneof 943 -java-operationBased-hero_details 941 +java-operationBased-hero_details 942 java-operationBased-used_arguments 941 java-operationBased-not_all_combinations_are_needed 938 java-operationBased-simple_inline_fragment 919 kotlin-responseBased-mutation_create_review_semantic_naming 918 kotlin-operationBased-named_fragment_with_variables 918 +java-operationBased-introspection_query 916 java-operationBased-fieldset_with_multiple_super 915 -java-operationBased-introspection_query 915 java-operationBased-inline_fragment_with_include_directive 913 java-operationBased-union_fragment 898 kotlin-operationBased-fragment_used_twice 893 @@ -105,7 +105,7 @@ kotlin-operationBased-named_fragment_inside_inline_fragment java-operationBased-hero_details_semantic_naming 803 kotlin-operationBased-inline_fragment_merge_fields 799 java-operationBased-operationbased2_ex7 798 -java-operationBased-suppressed_warnings 797 +java-operationBased-suppressed_warnings 798 kotlin-operationBased-root_query_inline_fragment 793 kotlin-responseBased-inline_fragments_with_friends 790 kotlin-operationBased-target_name 789 @@ -118,8 +118,8 @@ kotlin-responseBased-simple_union java-operationBased-typename_always_first 754 kotlin-operationBased-inline_fragments_with_friends 739 kotlin-responseBased-fragments_same_type_condition 738 -java-operationBased-input_object_variable_and_argument 736 -java-operationBased-input_object_variable_and_argument_with_generated_methods 736 +java-operationBased-input_object_variable_and_argument 737 +java-operationBased-input_object_variable_and_argument_with_generated_methods 737 java-operationBased-interface_on_interface 736 java-operationBased-root_query_fragment 717 kotlin-operationBased-simple_fragment_with_inline_fragments 714 @@ -137,11 +137,11 @@ kotlin-responseBased-java_java_optionals kotlin-responseBased-java_jetbrains_annotations 674 kotlin-responseBased-java_jsr305_annotations 674 kotlin-operationBased-fragments_same_type_condition 667 +java-operationBased-hero_with_review 667 java-operationBased-capitalized_fields 666 -java-operationBased-hero_with_review 666 kotlin-operationBased-simple_union 665 java-operationBased-recursive_selection 661 -java-operationBased-deprecation 659 +java-operationBased-deprecation 660 kotlin-responseBased-fragment_with_multiple_fieldsets 659 kotlin-responseBased-test_inline 657 kotlin-responseBased-named_fragment_without_implementation 651 @@ -151,10 +151,10 @@ kotlin-operationBased-decapitalized_fields kotlin-responseBased-hero_details 647 kotlin-operationBased-deprecated_merged_field 646 kotlin-operationBased-inline_fragment_inside_inline_fragment 645 -java-operationBased-hero_name_query_long_name 641 +java-operationBased-hero_name_query_long_name 642 kotlin-responseBased-inline_fragment_inside_inline_fragment 639 +java-operationBased-variable_default_value 639 java-operationBased-field_with_include_directive 638 -java-operationBased-variable_default_value 638 java-operationBased-custom_scalar_type 637 kotlin-operationBased-not_all_combinations_are_needed 637 kotlin-responseBased-java_primitive_types 636 @@ -170,16 +170,16 @@ java-operationBased-java8annotation kotlin-responseBased-not_all_combinations_are_needed 612 kotlin-responseBased-simple_inline_fragment 611 kotlin-responseBased-decapitalized_fields 610 +java-operationBased-optional 608 kotlin-responseBased-fieldset_with_multiple_super 607 -java-operationBased-optional 607 kotlin-responseBased-input_object_variable_and_argument 604 java-operationBased-inline_fragment_for_non_optional_field 602 kotlin-responseBased-reserved_keywords 600 -java-operationBased-enum_field 595 +java-operationBased-enum_field 596 java-operationBased-two_heroes_unique 591 java-operationBased-inline_fragment_type_coercion 587 kotlin-operationBased-test_inline 581 -java-operationBased-list_field_clash 576 +java-operationBased-list_field_clash 577 java-operationBased-inline_fragment_simple 573 kotlin-operationBased-reserved_keywords 573 kotlin-responseBased-path_vs_flat_accessors 558 @@ -213,8 +213,8 @@ kotlin-operationBased-monomorphic kotlin-responseBased-monomorphic 475 kotlin-operationBased-interface_always_nested 474 kotlin-responseBased-enum_field 469 -java-operationBased-enums_as_sealed 465 -java-operationBased-case_sensitive_enum 462 +java-operationBased-enums_as_sealed 466 +java-operationBased-case_sensitive_enum 463 kotlin-responseBased-optional 460 java-operationBased-nonnull 457 kotlin-operationBased-hero_name 455 diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected index 31170603a60..20d12d51634 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected index 515ef40fc30..e2e5322b056 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected index 75668d9bb66..787966cbf4c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected index 8d9fe106c83..02d793338e3 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected index d857a98e65b..faf65b65316 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected index dd2f87521f4..601b34bcfc8 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected index ece3ac2613f..393aceb7567 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public class Direction { public static EnumType type = new EnumType("Direction", Arrays.asList("South", "North", "East")); @@ -23,13 +24,13 @@ public class Direction { public String rawValue; - public Direction(String rawValue) { + private Direction(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Direction safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "South": return Direction.South; case "North": return Direction.North; case "East": return Direction.East; @@ -47,7 +48,7 @@ public class Direction { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -57,7 +58,7 @@ public class Direction { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -65,7 +66,7 @@ public class Direction { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected index 5f1489070fe..5065672fe73 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected @@ -10,6 +10,7 @@ import java.lang.Object; import java.lang.Override; import java.lang.String; import java.util.Arrays; +import java.util.Objects; public class RenamedEnum { public static EnumType type = new EnumType("ReservedEnum", Arrays.asList("VALUE")); @@ -18,12 +19,12 @@ public class RenamedEnum { public String rawValue; - public RenamedEnum(String rawValue) { + private RenamedEnum(String rawValue) { this.rawValue = rawValue; } public static RenamedEnum safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "VALUE": return RenamedEnum.VALUE; default: return new RenamedEnum.UNKNOWN__(rawValue); } @@ -39,7 +40,7 @@ public class RenamedEnum { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -49,7 +50,7 @@ public class RenamedEnum { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -57,7 +58,7 @@ public class RenamedEnum { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected index 6b56d6b248d..286be74690a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected index 34a1a9e4411..4fabca5c80b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected index c4c11b86e19..b162e67d684 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected @@ -11,6 +11,7 @@ import java.lang.Override; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; /** * The episodes in the Star Wars trilogy @@ -30,13 +31,13 @@ public class Episode { public String rawValue; - public Episode(String rawValue) { + private Episode(String rawValue) { this.rawValue = rawValue; } @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { - switch(rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "NEWHOPE": return Episode.NEWHOPE; case "EMPIRE": return Episode.EMPIRE; case "JEDI": return Episode.JEDI; @@ -56,7 +57,7 @@ public class Episode { private transient volatile String $toString; - public UNKNOWN__(String rawValue) { + private UNKNOWN__(String rawValue) { super(rawValue); } @@ -66,7 +67,7 @@ public class Episode { return true; } if (o instanceof UNKNOWN__) { - return true; + return super.equals(o); } return false; } @@ -74,7 +75,7 @@ public class Episode { @Override public int hashCode() { if (!$hashCodeMemoized) { - int __h = 1; + int __h = super.hashCode(); $hashCode = __h; $hashCodeMemoized = true; } From f370c5bb321dc4e8dc55db2a6174d0622f412bcd Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 16:21:39 +0200 Subject: [PATCH 04/11] Fix test --- .../integration-tests/src/commonTest/kotlin/test/EnumTest.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt index b9bd9eb3068..e3cefc44348 100644 --- a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt +++ b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt @@ -8,9 +8,6 @@ class EnumTest { @Test fun safeValueOf() { assertEquals(Episode.EMPIRE, Episode.safeValueOf("EMPIRE")) - - // Note: Episode is generated as a sealed class (sealedClassesForEnumsMatching) for this - // to work both with Kotlin and Java codegens - assertEquals(Episode.UNKNOWN__("NEW_EPISODE"), Episode.safeValueOf("NEW_EPISODE")) + assertEquals(Episode.UNKNOWN__::class, Episode.safeValueOf("NEW_EPISODE")::class) } } From 4b67290c702efefd24a53250d76d9b10e417f2ec Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 17:22:34 +0200 Subject: [PATCH 05/11] Re-generate expected --- .../enum_field/type/GravityAsEnum.java.expected | 3 ++- .../src/test/graphql/com/example/measurements | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected index 471e8249179..7fda22d0d39 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected @@ -10,6 +10,7 @@ import java.lang.Deprecated; import java.lang.String; import java.lang.SuppressWarnings; import java.util.Arrays; +import java.util.Objects; public enum GravityAsEnum { TOP("TOP"), @@ -57,7 +58,7 @@ public enum GravityAsEnum { @SuppressWarnings("deprecation") public static GravityAsEnum safeValueOf(String rawValue) { - switch (rawValue) { + switch (Objects.requireNonNull(rawValue)) { case "TOP": return GravityAsEnum.TOP; case "CENTER": return GravityAsEnum.CENTER; case "BOTTOM": return GravityAsEnum.BOTTOM; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index 61ba36b9760..db082eadae1 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 204905 +aggregate-all 204906 aggregate-kotlin-responseBased 65795 aggregate-kotlin-operationBased 42408 aggregate-kotlin-compat 0 -aggregate-java-operationBased 96702 +aggregate-java-operationBased 96703 java-operationBased-fragments_with_defer_and_include_directives 5600 kotlin-operationBased-fragments_with_defer_and_include_directives 3488 @@ -175,7 +175,7 @@ kotlin-responseBased-fieldset_with_multiple_super kotlin-responseBased-input_object_variable_and_argument 604 java-operationBased-inline_fragment_for_non_optional_field 602 kotlin-responseBased-reserved_keywords 600 -java-operationBased-enum_field 596 +java-operationBased-enum_field 597 java-operationBased-two_heroes_unique 591 java-operationBased-inline_fragment_type_coercion 587 kotlin-operationBased-test_inline 581 From 8fffd4062470855287537d9c7dbadcd53b94a0da Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 18:12:50 +0200 Subject: [PATCH 06/11] Add a comment to checkNotNull --- .../java/com/apollographql/apollo3/api/java/Assertions.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/apollo-api-java/src/main/java/com/apollographql/apollo3/api/java/Assertions.java b/libraries/apollo-api-java/src/main/java/com/apollographql/apollo3/api/java/Assertions.java index c02f8958675..7e194fbafed 100644 --- a/libraries/apollo-api-java/src/main/java/com/apollographql/apollo3/api/java/Assertions.java +++ b/libraries/apollo-api-java/src/main/java/com/apollographql/apollo3/api/java/Assertions.java @@ -1,6 +1,7 @@ package com.apollographql.apollo3.api.java; public class Assertions { + // A version of Objects.requireNonNull that allows a customized message public static T checkNotNull(T value, String errorMessage) { if (value == null) { throw new NullPointerException(errorMessage); @@ -8,4 +9,4 @@ public static T checkNotNull(T value, String errorMessage) { return value; } -} \ No newline at end of file +} From 15382be5f0874e715e5c89a7f849b0653c46fc37 Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 17 May 2024 19:34:55 +0200 Subject: [PATCH 07/11] Fix hashCode equals and toString --- .../codegen/java/helpers/DataClass.kt | 95 +++++++------------ .../codegen/java/schema/EnumAsClassBuilder.kt | 34 ++++++- .../type/Enum.java.expected | 31 ++---- .../deprecation/type/Episode.java.expected | 31 ++---- .../enum_field/type/Gravity.java.expected | 31 ++---- .../enums_as_sealed/type/Enum.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../hero_details/type/hero_type.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Race.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/__TypeKind.java.expected | 31 ++---- .../type/AmenityCategory.java.expected | 31 ++---- .../src/test/graphql/com/example/measurements | 56 +++++------ .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../optional/type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Direction.java.expected | 31 ++---- .../type/renamedEnum.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- .../type/Episode.java.expected | 31 ++---- tests/enums/src/test/kotlin/test/EnumsTest.kt | 1 + 30 files changed, 252 insertions(+), 740 deletions(-) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt index 618bbf0a06d..acd94fb69ee 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/helpers/DataClass.kt @@ -30,7 +30,7 @@ import javax.lang.model.element.Modifier internal fun TypeSpec.Builder.makeClassFromParameters( generateMethods: List, parameters: List, - className: ClassName, + className: ClassName ): TypeSpec.Builder { addMethod( MethodSpec.constructorBuilder() @@ -56,7 +56,7 @@ internal fun TypeSpec.Builder.makeClassFromParameters( internal fun TypeSpec.Builder.addGeneratedMethods( className: ClassName, - generateMethods: List = listOf(EQUALS_HASH_CODE, TO_STRING), + generateMethods: List = listOf(EQUALS_HASH_CODE, TO_STRING) ): TypeSpec.Builder { return applyIf(generateMethods.contains(EQUALS_HASH_CODE)) { withEqualsImplementation(className) } .applyIf(generateMethods.contains(EQUALS_HASH_CODE)) { withHashCodeImplementation() } @@ -69,7 +69,7 @@ internal fun TypeSpec.Builder.addGeneratedMethods( internal fun TypeSpec.Builder.makeClassFromProperties( generateMethods: List, fields: List, - className: ClassName, + className: ClassName ): TypeSpec.Builder { addMethod( MethodSpec.constructorBuilder() @@ -117,23 +117,20 @@ internal fun TypeSpec.Builder.withToStringImplementation(className: ClassName): .indent() .add("\n+ \$S;\n", "}") .unindent() - .build() - ) + .build()) .endControlFlow() .addStatement("return \$L", MEMOIZED_TO_STRING_VAR) .build() - return addField( - FieldSpec.builder(JavaClassNames.String, MEMOIZED_TO_STRING_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() - ) - .addMethod( - MethodSpec.methodBuilder("toString") - .addAnnotation(JavaClassNames.Override) - .addModifiers(Modifier.PUBLIC) - .returns(JavaClassNames.String) - .addCode(methodCode()) - .build() - ) + return addField(FieldSpec.builder(JavaClassNames.String, MEMOIZED_TO_STRING_VAR, Modifier.PRIVATE, Modifier.VOLATILE, + Modifier.TRANSIENT) + .build()) + .addMethod(MethodSpec.methodBuilder("toString") + .addAnnotation(JavaClassNames.Override) + .addModifiers(Modifier.PUBLIC) + .returns(JavaClassNames.String) + .addCode(methodCode()) + .build()) } private fun List.equalsCode(): CodeBlock = filter { !it.hasModifier(Modifier.STATIC) } @@ -146,7 +143,8 @@ private fun FieldSpec.equalsCode() = .let { if (type.isPrimitive) { if (type == TypeName.DOUBLE) { - it.add("Double.doubleToLongBits(this.\$L) == Double.doubleToLongBits(that.\$L)", name, name) + it.add("Double.doubleToLongBits(this.\$L) == Double.doubleToLongBits(that.\$L)", + name, name) } else { it.add("this.\$L == that.\$L", name, name) } @@ -157,7 +155,6 @@ private fun FieldSpec.equalsCode() = .build() internal fun TypeSpec.Builder.withEqualsImplementation(className: ClassName): TypeSpec.Builder { - val hasSuperClass = build().superclass != ClassName.OBJECT fun methodCode(typeJavaClass: ClassName) = CodeBlock.builder() .beginControlFlow("if (o == this)") @@ -166,18 +163,10 @@ internal fun TypeSpec.Builder.withEqualsImplementation(className: ClassName): Ty .beginControlFlow("if (o instanceof \$T)", typeJavaClass) .apply { if (fieldSpecs.isEmpty()) { - if (hasSuperClass) { - add("return super.equals(o);\n") - } else { - add("return true;\n") - } + add("return true;\n") } else { addStatement("\$T that = (\$T) o", typeJavaClass, typeJavaClass) - if (hasSuperClass) { - add("return super.equals(o) && $L;\n", fieldSpecs.equalsCode()) - } else { - add("return $L;\n", fieldSpecs.equalsCode()) - } + add("return $L;\n", if (fieldSpecs.isEmpty()) "true" else fieldSpecs.equalsCode()) } } .endControlFlow() @@ -190,12 +179,10 @@ internal fun TypeSpec.Builder.withEqualsImplementation(className: ClassName): Ty .returns(TypeName.BOOLEAN) .addParameter(ParameterSpec.builder(TypeName.OBJECT, "o").build()) .addCode(methodCode(className)) - .build() - ) + .build()) } internal fun TypeSpec.Builder.withHashCodeImplementation(): TypeSpec.Builder { - val hasSuperClass = build().superclass != ClassName.OBJECT fun hashFieldCode(field: FieldSpec) = CodeBlock.builder() .addStatement("$__h *= 1000003") @@ -215,41 +202,29 @@ internal fun TypeSpec.Builder.withHashCodeImplementation(): TypeSpec.Builder { fun methodCode() = CodeBlock.builder() .beginControlFlow("if (!\$L)", MEMOIZED_HASH_CODE_FLAG_VAR) - .addStatement( - if (hasSuperClass) { - "int $__h = super.hashCode()" - } else { - "int $__h = 1" - } - ) - .add( - fieldSpecs - .filter { !it.hasModifier(Modifier.STATIC) } - .filter { !it.hasModifier(Modifier.TRANSIENT) } - .map(::hashFieldCode) - .fold(CodeBlock.builder(), CodeBlock.Builder::add) - .build() - ) + .addStatement("int $__h = 1") + .add(fieldSpecs + .filter { !it.hasModifier(Modifier.STATIC) } + .filter { !it.hasModifier(Modifier.TRANSIENT) } + .map(::hashFieldCode) + .fold(CodeBlock.builder(), CodeBlock.Builder::add) + .build()) .addStatement("\$L = $__h", MEMOIZED_HASH_CODE_VAR) .addStatement("\$L = true", MEMOIZED_HASH_CODE_FLAG_VAR) .endControlFlow() .addStatement("return \$L", MEMOIZED_HASH_CODE_VAR) .build() - return addField( - FieldSpec.builder(TypeName.INT, MEMOIZED_HASH_CODE_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() - ) - .addField( - FieldSpec.builder(TypeName.BOOLEAN, MEMOIZED_HASH_CODE_FLAG_VAR, Modifier.PRIVATE, Modifier.VOLATILE, Modifier.TRANSIENT).build() - ) - .addMethod( - MethodSpec.methodBuilder("hashCode") - .addAnnotation(JavaClassNames.Override) - .addModifiers(Modifier.PUBLIC) - .returns(TypeName.INT) - .addCode(methodCode()) - .build() - ) + return addField(FieldSpec.builder(TypeName.INT, MEMOIZED_HASH_CODE_VAR, Modifier.PRIVATE, Modifier.VOLATILE, + Modifier.TRANSIENT).build()) + .addField(FieldSpec.builder(TypeName.BOOLEAN, MEMOIZED_HASH_CODE_FLAG_VAR, Modifier.PRIVATE, + Modifier.VOLATILE, Modifier.TRANSIENT).build()) + .addMethod(MethodSpec.methodBuilder("hashCode") + .addAnnotation(JavaClassNames.Override) + .addModifiers(Modifier.PUBLIC) + .returns(TypeName.INT) + .addCode(methodCode()) + .build()) } diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt index 8a3546f94f1..aeeb2d3514d 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt @@ -10,7 +10,6 @@ import com.apollographql.apollo3.compiler.codegen.java.JavaSchemaContext import com.apollographql.apollo3.compiler.codegen.java.L import com.apollographql.apollo3.compiler.codegen.java.S import com.apollographql.apollo3.compiler.codegen.java.T -import com.apollographql.apollo3.compiler.codegen.java.helpers.addGeneratedMethods import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDescription import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeSuppressDeprecation import com.apollographql.apollo3.compiler.codegen.typePackageName @@ -22,6 +21,7 @@ import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec import com.squareup.javapoet.MethodSpec import com.squareup.javapoet.ParameterSpec +import com.squareup.javapoet.TypeName import com.squareup.javapoet.TypeSpec import javax.lang.model.element.Modifier @@ -118,7 +118,37 @@ internal class EnumAsClassBuilder( .addCode("super($rawValue);\n") .build() ) - .addGeneratedMethods(ClassName.get("", Identifier.UNKNOWN__)) + .addMethod( + MethodSpec.methodBuilder("equals") + .addModifiers(Modifier.PUBLIC) + .addAnnotation(JavaClassNames.Override) + .addParameter(ParameterSpec.builder(JavaClassNames.Object, "other").build()) + .returns(TypeName.BOOLEAN) + .addCode( + CodeBlock.builder() + .add("if (this == other) return true;\n") + .add("if (!(other instanceof $L)) return false;\n", Identifier.UNKNOWN__) + .addStatement("return rawValue.equals((($L) other).rawValue)", Identifier.UNKNOWN__) + .build() + ) + .build() + ) + .addMethod( + MethodSpec.methodBuilder("hashCode") + .addModifiers(Modifier.PUBLIC) + .addAnnotation(JavaClassNames.Override) + .returns(TypeName.INT) + .addCode("return rawValue.hashCode();\n") + .build() + ) + .addMethod( + MethodSpec.methodBuilder("toString") + .addModifiers(Modifier.PUBLIC) + .addAnnotation(JavaClassNames.Override) + .returns(JavaClassNames.String) + .addCode("return \"$L(\" + rawValue + \")\";\n", Identifier.UNKNOWN__) + .build() + ) .build() } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected index e65ec250511..471f0ff4a40 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected @@ -45,44 +45,25 @@ public class Enum { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Enum { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected index c75f866ec41..cc47e3d94e9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected @@ -39,44 +39,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected index 86b121e2134..0956a3f4856 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected @@ -54,44 +54,25 @@ public class Gravity { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Gravity { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected index 703877b5d0a..3de6465f38d 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected @@ -48,44 +48,25 @@ public class Enum { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Enum { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected index 539442bbe5b..bdfa2cf6a7b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected index fc25ac250c5..aa5afabec92 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected @@ -40,44 +40,25 @@ public class Hero_type { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Hero_type { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected index 53079e6755b..672d23626e8 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected index 7bff54aa4d1..987b57999c9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected index e7b90d19be9..61a5efdaead 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected @@ -40,44 +40,25 @@ public class Race { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Race { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected index 2cd7a54063b..03aadd164ab 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected index 43f0190820b..db024465ec6 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected index db2ba61d655..b125db13d04 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected index f3f7d4ded91..7fab5dd3e87 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected index b039efd0f1c..3afdadf0722 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected @@ -55,44 +55,25 @@ public class __TypeKind { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends __TypeKind { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected index dd68860e930..71193c3d761 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected @@ -37,44 +37,25 @@ public class AmenityCategory { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends AmenityCategory { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index db082eadae1..c6720740079 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/measurements +++ b/libraries/apollo-compiler/src/test/graphql/com/example/measurements @@ -2,36 +2,36 @@ // If you updated the codegen and test fixtures, you should commit this file too. Test: Total LOC: -aggregate-all 204906 +aggregate-all 204412 aggregate-kotlin-responseBased 65795 aggregate-kotlin-operationBased 42408 aggregate-kotlin-compat 0 -aggregate-java-operationBased 96703 +aggregate-java-operationBased 96209 java-operationBased-fragments_with_defer_and_include_directives 5600 kotlin-operationBased-fragments_with_defer_and_include_directives 3488 java-operationBased-data_builders 3031 -java-operationBased-mutation_create_review 2436 kotlin-responseBased-fragment_with_inline_fragment 2422 +java-operationBased-mutation_create_review 2417 kotlin-responseBased-data_builders 2355 -java-operationBased-fragment_with_inline_fragment 2262 +java-operationBased-fragment_with_inline_fragment 2243 kotlin-operationBased-data_builders 2004 java-operationBased-nested_named_fragments 1910 java-operationBased-fragment_spread_with_include_directive 1667 -java-operationBased-union_inline_fragments 1667 -java-operationBased-unique_type_name 1644 +java-operationBased-union_inline_fragments 1648 kotlin-responseBased-nested_named_fragments 1643 -java-operationBased-inline_fragment_intersection 1638 -java-operationBased-input_object_type 1626 -java-operationBased-mutation_create_review_semantic_naming 1610 +java-operationBased-unique_type_name 1625 +java-operationBased-inline_fragment_intersection 1619 +java-operationBased-input_object_type 1607 java-operationBased-root_query_fragment_with_nested_fragments 1607 +java-operationBased-mutation_create_review_semantic_naming 1591 java-operationBased-simple_fragment 1505 java-operationBased-named_fragment_delegate 1493 kotlin-responseBased-mutation_create_review 1454 java-operationBased-named_fragment_with_variables 1405 kotlin-responseBased-named_fragment_delegate 1371 kotlin-responseBased-unique_type_name 1354 -java-operationBased-nested_conditional_inline 1345 +java-operationBased-nested_conditional_inline 1326 java-operationBased-fragment_used_twice 1305 kotlin-operationBased-fragment_with_inline_fragment 1297 java-operationBased-multiple_fragments 1294 @@ -43,22 +43,22 @@ kotlin-responseBased-inline_fragment_intersection java-operationBased-two_heroes_with_friends 1241 java-operationBased-inline_fragment_merge_fields 1229 kotlin-responseBased-simple_fragment 1195 -java-operationBased-named_fragment_inside_inline_fragment 1187 java-operationBased-fragments_with_type_condition 1183 -java-operationBased-target_name 1169 +java-operationBased-named_fragment_inside_inline_fragment 1168 kotlin-responseBased-fragment_used_twice 1157 kotlin-operationBased-inline_fragment_intersection 1154 java-operationBased-java_jetbrains_annotations 1154 java-operationBased-java_android_annotations 1151 java-operationBased-java_jsr305_annotations 1151 +java-operationBased-target_name 1150 kotlin-operationBased-union_inline_fragments 1147 kotlin-responseBased-union_inline_fragments 1147 java-operationBased-java_guava_optionals 1135 java-operationBased-java_java_optionals 1135 java-operationBased-java_apollo_optionals 1134 -java-operationBased-root_query_inline_fragment 1123 kotlin-operationBased-fragment_spread_with_include_directive 1121 kotlin-operationBased-unique_type_name 1109 +java-operationBased-root_query_inline_fragment 1104 kotlin-responseBased-fragments_with_type_condition 1102 kotlin-responseBased-nested_conditional_inline 1085 java-operationBased-java_primitive_types 1077 @@ -66,11 +66,11 @@ kotlin-responseBased-multiple_fragments kotlin-responseBased-named_fragment_with_variables 1067 java-operationBased-simple_fragment_with_inline_fragments 1066 kotlin-operationBased-root_query_fragment_with_nested_fragments 1065 -java-operationBased-inline_fragments_with_friends 1057 java-operationBased-fragment_spread_with_nested_fields 1054 kotlin-responseBased-simple_fragment_with_inline_fragments 1052 kotlin-operationBased-simple_fragment 1043 java-operationBased-operationbased2_ex8 1042 +java-operationBased-inline_fragments_with_friends 1038 kotlin-operationBased-named_fragment_delegate 1013 java-operationBased-decapitalized_fields 993 java-operationBased-simple_union 975 @@ -79,16 +79,16 @@ kotlin-responseBased-operationbased2_ex8 java-operationBased-deprecated_merged_field 950 kotlin-operationBased-nested_conditional_inline 948 java-operationBased-input_object_oneof 943 -java-operationBased-hero_details 942 java-operationBased-used_arguments 941 java-operationBased-not_all_combinations_are_needed 938 +java-operationBased-hero_details 923 java-operationBased-simple_inline_fragment 919 kotlin-responseBased-mutation_create_review_semantic_naming 918 kotlin-operationBased-named_fragment_with_variables 918 -java-operationBased-introspection_query 916 java-operationBased-fieldset_with_multiple_super 915 java-operationBased-inline_fragment_with_include_directive 913 java-operationBased-union_fragment 898 +java-operationBased-introspection_query 897 kotlin-operationBased-fragment_used_twice 893 java-operationBased-inline_fragment_inside_inline_fragment 883 java-operationBased-test_inline 881 @@ -105,12 +105,12 @@ kotlin-operationBased-named_fragment_inside_inline_fragment java-operationBased-hero_details_semantic_naming 803 kotlin-operationBased-inline_fragment_merge_fields 799 java-operationBased-operationbased2_ex7 798 -java-operationBased-suppressed_warnings 798 kotlin-operationBased-root_query_inline_fragment 793 kotlin-responseBased-inline_fragments_with_friends 790 kotlin-operationBased-target_name 789 kotlin-responseBased-deprecated_merged_field 786 kotlin-responseBased-named_fragment_inside_inline_fragment 785 +java-operationBased-suppressed_warnings 779 java-operationBased-path_vs_flat_accessors 776 java-operationBased-reserved_keywords 772 kotlin-responseBased-root_query_inline_fragment 769 @@ -118,9 +118,9 @@ kotlin-responseBased-simple_union java-operationBased-typename_always_first 754 kotlin-operationBased-inline_fragments_with_friends 739 kotlin-responseBased-fragments_same_type_condition 738 -java-operationBased-input_object_variable_and_argument 737 -java-operationBased-input_object_variable_and_argument_with_generated_methods 737 java-operationBased-interface_on_interface 736 +java-operationBased-input_object_variable_and_argument 718 +java-operationBased-input_object_variable_and_argument_with_generated_methods 718 java-operationBased-root_query_fragment 717 kotlin-operationBased-simple_fragment_with_inline_fragments 714 kotlin-operationBased-fragment_spread_with_nested_fields 705 @@ -137,23 +137,21 @@ kotlin-responseBased-java_java_optionals kotlin-responseBased-java_jetbrains_annotations 674 kotlin-responseBased-java_jsr305_annotations 674 kotlin-operationBased-fragments_same_type_condition 667 -java-operationBased-hero_with_review 667 java-operationBased-capitalized_fields 666 kotlin-operationBased-simple_union 665 java-operationBased-recursive_selection 661 -java-operationBased-deprecation 660 kotlin-responseBased-fragment_with_multiple_fieldsets 659 kotlin-responseBased-test_inline 657 kotlin-responseBased-named_fragment_without_implementation 651 kotlin-operationBased-used_arguments 651 kotlin-operationBased-union_fragment 650 +java-operationBased-hero_with_review 648 kotlin-operationBased-decapitalized_fields 647 kotlin-responseBased-hero_details 647 kotlin-operationBased-deprecated_merged_field 646 kotlin-operationBased-inline_fragment_inside_inline_fragment 645 -java-operationBased-hero_name_query_long_name 642 +java-operationBased-deprecation 641 kotlin-responseBased-inline_fragment_inside_inline_fragment 639 -java-operationBased-variable_default_value 639 java-operationBased-field_with_include_directive 638 java-operationBased-custom_scalar_type 637 kotlin-operationBased-not_all_combinations_are_needed 637 @@ -161,7 +159,9 @@ kotlin-responseBased-java_primitive_types kotlin-responseBased-inline_fragment_merge_fields 629 kotlin-operationBased-inline_fragment_with_include_directive 627 java-operationBased-hero_name 626 +java-operationBased-hero_name_query_long_name 623 kotlin-operationBased-fieldset_with_multiple_super 620 +java-operationBased-variable_default_value 620 kotlin-operationBased-simple_inline_fragment 618 kotlin-operationBased-named_fragment_without_implementation 616 kotlin-responseBased-operationbased2_ex7 616 @@ -170,18 +170,18 @@ java-operationBased-java8annotation kotlin-responseBased-not_all_combinations_are_needed 612 kotlin-responseBased-simple_inline_fragment 611 kotlin-responseBased-decapitalized_fields 610 -java-operationBased-optional 608 kotlin-responseBased-fieldset_with_multiple_super 607 kotlin-responseBased-input_object_variable_and_argument 604 java-operationBased-inline_fragment_for_non_optional_field 602 kotlin-responseBased-reserved_keywords 600 -java-operationBased-enum_field 597 java-operationBased-two_heroes_unique 591 +java-operationBased-optional 589 java-operationBased-inline_fragment_type_coercion 587 kotlin-operationBased-test_inline 581 -java-operationBased-list_field_clash 577 +java-operationBased-enum_field 578 java-operationBased-inline_fragment_simple 573 kotlin-operationBased-reserved_keywords 573 +java-operationBased-list_field_clash 558 kotlin-responseBased-path_vs_flat_accessors 558 kotlin-responseBased-hero_with_review 551 kotlin-responseBased-hero_details_semantic_naming 548 @@ -213,8 +213,6 @@ kotlin-operationBased-monomorphic kotlin-responseBased-monomorphic 475 kotlin-operationBased-interface_always_nested 474 kotlin-responseBased-enum_field 469 -java-operationBased-enums_as_sealed 466 -java-operationBased-case_sensitive_enum 463 kotlin-responseBased-optional 460 java-operationBased-nonnull 457 kotlin-operationBased-hero_name 455 @@ -222,6 +220,8 @@ kotlin-operationBased-capitalized_fields kotlin-responseBased-field_with_include_directive 453 java-operationBased-companion 449 kotlin-responseBased-inline_fragment_type_coercion 448 +java-operationBased-enums_as_sealed 447 +java-operationBased-case_sensitive_enum 444 java-operationBased-object 444 kotlin-responseBased-recursive_selection 439 kotlin-operationBased-inline_fragment_for_non_optional_field 434 diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected index 20d12d51634..503ccbcd7d8 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected index e2e5322b056..88a1d7d6a2f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected index 787966cbf4c..5cd2379b924 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected index 02d793338e3..e9c0cdc67ff 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected index faf65b65316..20d4dc4138b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected index 601b34bcfc8..8d173c1823f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected index 393aceb7567..1a1d951b1fb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected @@ -42,44 +42,25 @@ public class Direction { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Direction { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected index 5065672fe73..0ef983d3a91 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected @@ -34,44 +34,25 @@ public class RenamedEnum { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends RenamedEnum { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected index 286be74690a..23d9250a8c3 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected index 4fabca5c80b..eb4104d7ca0 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected index b162e67d684..d4457fffeda 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected @@ -51,44 +51,25 @@ public class Episode { * An enum value that wasn't known at compile time. */ public static class UNKNOWN__ extends Episode { - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - private transient volatile String $toString; - private UNKNOWN__(String rawValue) { super(rawValue); } @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof UNKNOWN__) { - return super.equals(o); - } - return false; + public boolean equals(Object other) { + if (this == other) return true; + if (!(other instanceof UNKNOWN__)) return false; + return rawValue.equals(((UNKNOWN__) other).rawValue); } @Override public int hashCode() { - if (!$hashCodeMemoized) { - int __h = super.hashCode(); - $hashCode = __h; - $hashCodeMemoized = true; - } - return $hashCode; + return rawValue.hashCode(); } @Override public String toString() { - if ($toString == null) { - $toString = "UNKNOWN__{" - + "}"; - } - return $toString; + return "UNKNOWN__(" + rawValue + ")"; } } } diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index 3b6a64904f2..39d06bf25d4 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -66,6 +66,7 @@ class EnumsTest { val unknown = enums.java.type.Gravity.safeValueOf("newGravity") assertEquals(enums.java.type.Gravity.UNKNOWN__::class.java, unknown::class.java) assertEquals("newGravity", unknown.rawValue) + assertEquals(enums.java.type.Gravity.safeValueOf("newGravity"), unknown) assertNotEquals(enums.java.type.Gravity.safeValueOf("newGravity2"), unknown) assertEquals(enums.java.type.Gravity.name, enums.java.type.Gravity.safeValueOf("name")) assertEquals(enums.java.type.Gravity.ordinal, enums.java.type.Gravity.safeValueOf("ordinal")) From 4631d2eae1d2e70a07ac52e1e900bdd7c6548514 Mon Sep 17 00:00:00 2001 From: BoD Date: Mon, 20 May 2024 10:44:11 +0200 Subject: [PATCH 08/11] Rename ApolloEnumConstructor to ApolloUnknownEnum and apply it to safeValueOf --- ...numConstructor.kt => ApolloUnknownEnum.kt} | 6 +- .../codegen/java/schema/EnumAsClassBuilder.kt | 4 + .../codegen/java/schema/EnumAsEnumBuilder.kt | 4 + .../compiler/codegen/kotlin/KotlinSymbols.kt | 2 +- .../kotlin/schema/EnumAsEnumBuilder.kt | 8 +- .../kotlin/schema/EnumAsSealedBuilder.kt | 15 +- .../schema/EnumResponseAdapterBuilder.kt | 2 + .../type/Enum.java.expected | 4 + .../case_sensitive_enum/type/Enum.kt.expected | 7 + .../adapter/Enum_ResponseAdapter.kt.expected | 3 + .../deprecation/type/Episode.java.expected | 4 + .../deprecation/type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../enum_field/type/Gravity.java.expected | 4 + .../type/GravityAsEnum.java.expected | 4 + .../enum_field/type/Gravity.kt.expected | 7 + .../enum_field/type/GravityAsEnum.kt.expected | 7 + .../GravityAsEnum_ResponseAdapter.kt.expected | 3 + .../Gravity_ResponseAdapter.kt.expected | 3 + .../enums_as_sealed/type/Enum.java.expected | 4 + .../enums_as_sealed/type/Enum.kt.expected | 14 +- .../adapter/Enum_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../hero_details/type/hero_type.java.expected | 4 + .../hero_type_ResponseAdapter.kt.expected | 3 + .../hero_details/type/hero_type.kt.expected | 7 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../hero_with_review/type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Race.java.expected | 4 + .../type/Race.kt.expected | 7 + .../adapter/Race_ResponseAdapter.kt.expected | 3 + .../type/Race.kt.expected | 7 + .../adapter/Race_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/__TypeKind.java.expected | 4 + .../type/__TypeKind.kt.expected | 7 + .../__TypeKind_ResponseAdapter.kt.expected | 3 + .../type/AmenityCategory.java.expected | 4 + .../type/AmenityCategory.kt.expected | 7 + ...menityCategory_ResponseAdapter.kt.expected | 3 + .../src/test/graphql/com/example/measurements | 130 +++++++++--------- .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../optional/type/Episode.java.expected | 4 + .../optional/type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Direction.java.expected | 4 + .../type/Direction.kt.expected | 7 + .../Direction_ResponseAdapter.kt.expected | 3 + .../type/renamedEnum.java.expected | 4 + .../renamedEnum_ResponseAdapter.kt.expected | 3 + .../target_name/type/renamedEnum.kt.expected | 7 + .../renamedEnum_ResponseAdapter.kt.expected | 3 + .../target_name/type/renamedEnum.kt.expected | 7 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../unique_type_name/type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../unique_type_name/type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + .../type/Episode.java.expected | 4 + .../type/Episode.kt.expected | 7 + .../Episode_ResponseAdapter.kt.expected | 3 + tests/enums/src/test/kotlin/test/EnumsTest.kt | 8 +- 108 files changed, 573 insertions(+), 81 deletions(-) rename libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/{ApolloEnumConstructor.kt => ApolloUnknownEnum.kt} (72%) diff --git a/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloEnumConstructor.kt b/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt similarity index 72% rename from libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloEnumConstructor.kt rename to libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt index a3821de3c10..f0e79111260 100644 --- a/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloEnumConstructor.kt +++ b/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt @@ -2,8 +2,8 @@ package com.apollographql.apollo3.annotations @RequiresOptIn( level = RequiresOptIn.Level.WARNING, - message = "The `UNKNOWN__` class represents GraphQL enums that are not present in the schema and whose `rawValue` cannot be checked at build time. You may want to update your schema instead of calling this constructor directly." + message = "The `UNKNOWN__` class represents GraphQL enums that are not present in the schema and whose `rawValue` cannot be checked at build time. You may want to update your schema instead of calling this directly." ) @Retention(AnnotationRetention.BINARY) -@Target(AnnotationTarget.CONSTRUCTOR) -annotation class ApolloEnumConstructor +@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR) +annotation class ApolloUnknownEnum diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt index aeeb2d3514d..f81bdd3bd78 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsClassBuilder.kt @@ -79,6 +79,10 @@ internal class EnumAsClassBuilder( ) .addMethod( MethodSpec.methodBuilder(safeValueOf) + .addJavadoc( + "Returns the ${enum.name} that represents the specified rawValue.\n" + + "Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly.\n", + ) .maybeSuppressDeprecation(enum.values) .addParameter(JavaClassNames.String, rawValue) .addModifiers(Modifier.PUBLIC) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt index ee75eb7a9d3..40374c82c5c 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/schema/EnumAsEnumBuilder.kt @@ -78,6 +78,10 @@ internal class EnumAsEnumBuilder( } .addMethod( MethodSpec.methodBuilder(safeValueOf) + .addJavadoc( + "Returns the ${enum.name} that represents the specified rawValue.\n" + + "Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly.\n", + ) .maybeSuppressDeprecation(enum.values) .addParameter(JavaClassNames.String, rawValue) .addModifiers(Modifier.PUBLIC) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt index bb5b99685f4..2d40dfb7f34 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt @@ -105,7 +105,7 @@ internal object KotlinSymbols { val ApolloAdaptableWith = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloAdaptableWith") val ApolloExperimental = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloExperimental") - val ApolloEnumConstructor = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloEnumConstructor") + val ApolloUnknownEnum = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloUnknownEnum") val JsExport = ClassName("kotlin.js", "JsExport") diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt index 4f414ed7c4e..e73087bfca7 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt @@ -123,6 +123,12 @@ internal class EnumAsEnumBuilder( private fun IrEnum.safeValueOfFunSpec(): FunSpec { val entries = if (context.isTargetLanguageVersionAtLeast(TargetLanguage.KOTLIN_1_9)) "entries" else "values()" return FunSpec.builder("safeValueOf") + .addKdoc( + "Returns the [%T] that represents the specified [rawValue].\n" + + "Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your schema instead of calling this function directly.\n", + selfClassName + ) + .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addParameter("rawValue", String:: class) .returns(selfClassName) @@ -163,4 +169,4 @@ internal class EnumAsEnumBuilder( .initializer("rawValue") .build() -} \ No newline at end of file +} diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt index 3eefb4b5c23..d1dcb52c850 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt @@ -89,7 +89,9 @@ internal class EnumAsSealedBuilder( private fun IrEnum.unknownValueTypeSpec(): TypeSpec { return TypeSpec.classBuilder("UNKNOWN__") - .addKdoc("An enum value that wasn't known at compile time.\nConstructor is annotated with [%T] to prevent instantiation outside of this file.", KotlinSymbols.ApolloEnumConstructor) + .addKdoc("An enum value that wasn't known at compile time.\n" + + "Note: the `UNKNOWN__` class represents GraphQL enums that are not present in the schema and whose `rawValue` cannot be checked at build time. You may want to update your schema instead of instantiating it directly." + ) .primaryConstructor(unknownValuePrimaryConstructorSpec) .superclass(selfClassName) .addSuperclassConstructorParameter("rawValue·=·rawValue") @@ -121,7 +123,12 @@ internal class EnumAsSealedBuilder( private fun IrEnum.safeValueOfFunSpec(): FunSpec { return FunSpec.builder(Identifier.safeValueOf) - .addKdoc("Returns the [%T] that represents the specified [rawValue].\n", selfClassName) + .addKdoc( + "Returns the [%T] that represents the specified [rawValue].\n" + + "Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your schema instead of calling this function directly.\n", + selfClassName + ) + .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addSuppressions(enum.values.any { it.deprecationReason != null }) .maybeAddOptIn(context.resolver, enum.values) .addParameter("rawValue", KotlinSymbols.String) @@ -132,7 +139,7 @@ internal class EnumAsSealedBuilder( .map { CodeBlock.of("%S·->·%T", it.name, it.valueClassName()) } .joinToCode(separator = "\n", suffix = "\n") ) - .addCode("else -> @OptIn(%T::class) %T(rawValue)\n", KotlinSymbols.ApolloEnumConstructor, unknownValueClassName()) + .addCode("else -> @OptIn(%T::class) %T(rawValue)\n", KotlinSymbols.ApolloUnknownEnum, unknownValueClassName()) .endControlFlow() .build() } @@ -169,7 +176,7 @@ internal class EnumAsSealedBuilder( private val unknownValuePrimaryConstructorSpec = FunSpec.constructorBuilder() - .addAnnotation(KotlinSymbols.ApolloEnumConstructor) + .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addParameter("rawValue", KotlinSymbols.String) .build() diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt index 6d346dd0eb5..d7ffacb170f 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt @@ -5,6 +5,7 @@ import com.apollographql.apollo3.compiler.codegen.kotlin.CgFile import com.apollographql.apollo3.compiler.codegen.kotlin.CgFileBuilder import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSchemaContext import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols +import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.requiresOptInAnnotation import com.apollographql.apollo3.compiler.codegen.responseAdapter import com.apollographql.apollo3.compiler.codegen.typeAdapterPackageName import com.apollographql.apollo3.compiler.ir.IrEnum @@ -42,6 +43,7 @@ internal class EnumResponseAdapterBuilder( private fun IrEnum.typeSpec(): TypeSpec { val adaptedTypeName = context.resolver.resolveSchemaType(enum.name) val fromResponseFunSpec = FunSpec.builder(Identifier.fromJson) + .addAnnotation(requiresOptInAnnotation(KotlinSymbols.ApolloUnknownEnum)) .addModifiers(KModifier.OVERRIDE) .addParameter(Identifier.reader, KotlinSymbols.JsonReader) .addParameter(Identifier.customScalarAdapters, KotlinSymbols.CustomScalarAdapters) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected index 471f0ff4a40..3eb4c73ab70 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/java/operationBased/case_sensitive_enum/type/Enum.java.expected @@ -30,6 +30,10 @@ public class Enum { this.rawValue = rawValue; } + /** + * Returns the Enum that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Enum safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected index b29f4869e76..3e8c0f889f4 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected @@ -5,6 +5,7 @@ // package com.example.case_sensitive_enum.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -50,6 +51,12 @@ public enum class Enum( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Enum] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Enum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected index c27ae2a899a..3d5b7e314d6 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.case_sensitive_enum.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.case_sensitive_enum.type.Enum +import kotlin.OptIn public object Enum_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Enum { val rawValue = reader.nextString()!! return Enum.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected index cc47e3d94e9..2cb7461ef7e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/java/operationBased/deprecation/type/Episode.java.expected @@ -26,6 +26,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected index bd9185d54c1..adaa92d4b02 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.deprecation.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -45,6 +46,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected index 2329202a48d..9b6850881ff 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.deprecation.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.deprecation.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected index 0956a3f4856..61cad078d99 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/Gravity.java.expected @@ -36,6 +36,10 @@ public class Gravity { this.rawValue = rawValue; } + /** + * Returns the Gravity that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Gravity safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected index 7fda22d0d39..54a0a17db1a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/java/operationBased/enum_field/type/GravityAsEnum.java.expected @@ -56,6 +56,10 @@ public enum GravityAsEnum { this.rawValue = rawValue; } + /** + * Returns the GravityAsEnum that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static GravityAsEnum safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected index e33d6924c84..02457891253 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected @@ -5,6 +5,7 @@ // package com.example.enum_field.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -55,6 +56,12 @@ public enum class Gravity( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Gravity] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: kotlin.String): Gravity = entries.find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected index e0a1c12aa38..7c7a42fba53 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected @@ -5,6 +5,7 @@ // package com.example.enum_field.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -69,6 +70,12 @@ public enum class GravityAsEnum( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [GravityAsEnum] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: kotlin.String): GravityAsEnum = entries.find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected index dfba59ad652..34fb1307db7 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.enum_field.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enum_field.type.GravityAsEnum +import kotlin.OptIn public object GravityAsEnum_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): GravityAsEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected index c7ed21c7b8e..080c8dbb85a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.enum_field.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enum_field.type.Gravity +import kotlin.OptIn public object Gravity_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Gravity { val rawValue = reader.nextString()!! return Gravity.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected index 3de6465f38d..69f5c160625 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/java/operationBased/enums_as_sealed/type/Enum.java.expected @@ -32,6 +32,10 @@ public class Enum { this.rawValue = rawValue; } + /** + * Returns the Enum that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Enum safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected index b1e48c7a334..fb4b6b96623 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected @@ -5,7 +5,7 @@ // package com.example.enums_as_sealed.type -import com.apollographql.apollo3.annotations.ApolloEnumConstructor +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Any import kotlin.Array @@ -23,7 +23,10 @@ public sealed class Enum( /** * Returns the [Enum] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. */ + @ApolloUnknownEnum @Suppress("DEPRECATION") public fun safeValueOf(rawValue: String): Enum = when(rawValue) { "north" -> north @@ -31,7 +34,7 @@ public sealed class Enum( "NORTH" -> NORTH "SOUTH" -> SOUTH "type" -> type_ - else -> @OptIn(ApolloEnumConstructor::class) UNKNOWN__(rawValue) + else -> @OptIn(ApolloUnknownEnum::class) UNKNOWN__(rawValue) } /** @@ -60,10 +63,11 @@ public sealed class Enum( /** * An enum value that wasn't known at compile time. - * Constructor is annotated with [ApolloEnumConstructor] to prevent instantiation outside of this - * file. + * Note: the `UNKNOWN__` class represents GraphQL enums that are not present in the schema and + * whose `rawValue` cannot be checked at build time. You may want to update your schema instead of + * instantiating it directly. */ - public class UNKNOWN__ @ApolloEnumConstructor constructor( + public class UNKNOWN__ @ApolloUnknownEnum constructor( rawValue: String, ) : Enum(rawValue = rawValue) { override fun equals(other: Any?): Boolean { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected index dafc0f9522b..8b786a31910 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.enums_as_sealed.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enums_as_sealed.type.Enum +import kotlin.OptIn public object Enum_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Enum { val rawValue = reader.nextString()!! return Enum.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected index bdfa2cf6a7b..ee2489dd157 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/java/operationBased/fragment_with_inline_fragment/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected index 52152a99f29..589d578b016 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.fragment_with_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 5bf34cfdf86..d4c20e64f05 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.fragment_with_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.fragment_with_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected index 52152a99f29..589d578b016 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.fragment_with_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 5bf34cfdf86..d4c20e64f05 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.fragment_with_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.fragment_with_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected index aa5afabec92..0a79a39075f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/java/operationBased/hero_details/type/hero_type.java.expected @@ -28,6 +28,10 @@ public class Hero_type { this.rawValue = rawValue; } + /** + * Returns the hero_type that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ public static Hero_type safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { case "human": return Hero_type.human; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected index 9e9d952afab..af55b6fd5e1 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.hero_details.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_details.type.Hero_type +import kotlin.OptIn public object Hero_type_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Hero_type { val rawValue = reader.nextString()!! return Hero_type.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected index 13b82eeddb7..3776fd65dbf 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected @@ -5,6 +5,7 @@ // package com.example.hero_details.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -45,6 +46,12 @@ public enum class Hero_type( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Hero_type] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Hero_type = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected index 672d23626e8..74c98f17fd0 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/java/operationBased/hero_name_query_long_name/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected index 11bde9141bc..5cdddf21c20 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.hero_name_query_long_name.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected index 511cfdb115e..eb0ef4a5c2e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.hero_name_query_long_name.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_name_query_long_name.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected index 987b57999c9..5cbb0c0fca0 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/java/operationBased/hero_with_review/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected index 7bc61f60096..e4b9a539ae3 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.hero_with_review.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected index 26ed8c1b542..3854c15fb8b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.hero_with_review.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_with_review.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected index 61a5efdaead..3489d6ceb70 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/java/operationBased/inline_fragment_intersection/type/Race.java.expected @@ -27,6 +27,10 @@ public class Race { this.rawValue = rawValue; } + /** + * Returns the Race that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ public static Race safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { case "WOOKIE": return Race.WOOKIE; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected index cc3843383bd..4caa331a3c0 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected @@ -5,6 +5,7 @@ // package com.example.inline_fragment_intersection.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -44,6 +45,12 @@ public enum class Race( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Race] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Race = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected index 31cdbe28745..b80342c5f7d 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.inline_fragment_intersection.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragment_intersection.type.Race +import kotlin.OptIn public object Race_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Race { val rawValue = reader.nextString()!! return Race.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected index cc3843383bd..4caa331a3c0 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected @@ -5,6 +5,7 @@ // package com.example.inline_fragment_intersection.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -44,6 +45,12 @@ public enum class Race( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Race] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Race = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected index 31cdbe28745..b80342c5f7d 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.inline_fragment_intersection.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragment_intersection.type.Race +import kotlin.OptIn public object Race_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Race { val rawValue = reader.nextString()!! return Race.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected index 03aadd164ab..e56626e1f10 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/java/operationBased/inline_fragments_with_friends/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected index 39e23f54637..99734f67bde 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.inline_fragments_with_friends.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected index 7b7fadaa606..1866e8a8771 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.inline_fragments_with_friends.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragments_with_friends.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected index 39e23f54637..99734f67bde 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.inline_fragments_with_friends.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected index 7b7fadaa606..1866e8a8771 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.inline_fragments_with_friends.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragments_with_friends.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected index db024465ec6..8b30c428c0a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/java/operationBased/input_object_type/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected index f460726d1b0..915a978488b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.input_object_type.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected index 50f4abec08b..b397ab531f9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.input_object_type.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_type.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected index b125db13d04..3da8869a706 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/java/operationBased/input_object_variable_and_argument/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected index 6cf7c520b51..9c15136d31a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.input_object_variable_and_argument.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected index eaeb2b49213..7e9a662473e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.input_object_variable_and_argument.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_variable_and_argument.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected index 7fab5dd3e87..9beec31de5c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/java/operationBased/input_object_variable_and_argument_with_generated_methods/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected index ee364c17382..b539206b754 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.input_object_variable_and_argument_with_generated_methods.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected index 9c688f79ee3..42be5a07863 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.input_object_variable_and_argument_with_generated_methods.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_variable_and_argument_with_generated_methods.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected index 3afdadf0722..2b3738995fe 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/java/operationBased/introspection_query/type/__TypeKind.java.expected @@ -37,6 +37,10 @@ public class __TypeKind { this.rawValue = rawValue; } + /** + * Returns the __TypeKind that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ public static __TypeKind safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { case "SCALAR": return __TypeKind.SCALAR; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected index ea015e40ff3..361eeae6ca9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected @@ -5,6 +5,7 @@ // package com.example.introspection_query.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -55,6 +56,12 @@ public enum class __TypeKind( ) public fun knownValues(): Array<__TypeKind> = knownEntries.toTypedArray() + /** + * Returns the [__TypeKind] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): __TypeKind = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected index 4d6c04c8831..d129ee74482 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.introspection_query.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.introspection_query.type.__TypeKind +import kotlin.OptIn public object __TypeKind_ResponseAdapter : Adapter<__TypeKind> { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): __TypeKind { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected index 71193c3d761..a3be1bf7724 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/java/operationBased/list_field_clash/type/AmenityCategory.java.expected @@ -25,6 +25,10 @@ public class AmenityCategory { this.rawValue = rawValue; } + /** + * Returns the AmenityCategory that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ public static AmenityCategory safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { case "Category0": return AmenityCategory.Category0; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected index 56361641878..e770ef314a3 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected @@ -5,6 +5,7 @@ // package com.example.list_field_clash.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -42,6 +43,12 @@ public enum class AmenityCategory( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [AmenityCategory] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): AmenityCategory = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected index 161957161fb..794f3598956 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.list_field_clash.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.list_field_clash.type.AmenityCategory +import kotlin.OptIn public object AmenityCategory_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): AmenityCategory { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index c6720740079..60eae506a9b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/measurements +++ b/libraries/apollo-compiler/src/test/graphql/com/example/measurements @@ -2,65 +2,65 @@ // If you updated the codegen and test fixtures, you should commit this file too. Test: Total LOC: -aggregate-all 204412 -aggregate-kotlin-responseBased 65795 -aggregate-kotlin-operationBased 42408 +aggregate-all 204877 +aggregate-kotlin-responseBased 66062 +aggregate-kotlin-operationBased 42498 aggregate-kotlin-compat 0 -aggregate-java-operationBased 96209 +aggregate-java-operationBased 96317 java-operationBased-fragments_with_defer_and_include_directives 5600 kotlin-operationBased-fragments_with_defer_and_include_directives 3488 java-operationBased-data_builders 3031 -kotlin-responseBased-fragment_with_inline_fragment 2422 -java-operationBased-mutation_create_review 2417 +kotlin-responseBased-fragment_with_inline_fragment 2432 +java-operationBased-mutation_create_review 2421 kotlin-responseBased-data_builders 2355 -java-operationBased-fragment_with_inline_fragment 2243 +java-operationBased-fragment_with_inline_fragment 2247 kotlin-operationBased-data_builders 2004 java-operationBased-nested_named_fragments 1910 java-operationBased-fragment_spread_with_include_directive 1667 -java-operationBased-union_inline_fragments 1648 +java-operationBased-union_inline_fragments 1652 kotlin-responseBased-nested_named_fragments 1643 -java-operationBased-unique_type_name 1625 -java-operationBased-inline_fragment_intersection 1619 -java-operationBased-input_object_type 1607 +java-operationBased-unique_type_name 1629 +java-operationBased-inline_fragment_intersection 1623 +java-operationBased-input_object_type 1611 java-operationBased-root_query_fragment_with_nested_fragments 1607 -java-operationBased-mutation_create_review_semantic_naming 1591 +java-operationBased-mutation_create_review_semantic_naming 1595 java-operationBased-simple_fragment 1505 java-operationBased-named_fragment_delegate 1493 -kotlin-responseBased-mutation_create_review 1454 +kotlin-responseBased-mutation_create_review 1464 java-operationBased-named_fragment_with_variables 1405 kotlin-responseBased-named_fragment_delegate 1371 -kotlin-responseBased-unique_type_name 1354 -java-operationBased-nested_conditional_inline 1326 +kotlin-responseBased-unique_type_name 1364 +java-operationBased-nested_conditional_inline 1330 +kotlin-operationBased-fragment_with_inline_fragment 1307 java-operationBased-fragment_used_twice 1305 -kotlin-operationBased-fragment_with_inline_fragment 1297 java-operationBased-multiple_fragments 1294 +kotlin-responseBased-input_object_type 1288 kotlin-responseBased-root_query_fragment_with_nested_fragments 1287 -kotlin-responseBased-input_object_type 1278 java-operationBased-nested_field_with_multiple_fieldsets 1271 kotlin-operationBased-nested_named_fragments 1269 -kotlin-responseBased-inline_fragment_intersection 1245 +kotlin-responseBased-inline_fragment_intersection 1255 java-operationBased-two_heroes_with_friends 1241 java-operationBased-inline_fragment_merge_fields 1229 kotlin-responseBased-simple_fragment 1195 java-operationBased-fragments_with_type_condition 1183 -java-operationBased-named_fragment_inside_inline_fragment 1168 +java-operationBased-named_fragment_inside_inline_fragment 1172 +kotlin-operationBased-inline_fragment_intersection 1164 kotlin-responseBased-fragment_used_twice 1157 -kotlin-operationBased-inline_fragment_intersection 1154 +kotlin-operationBased-union_inline_fragments 1157 +kotlin-responseBased-union_inline_fragments 1157 java-operationBased-java_jetbrains_annotations 1154 +java-operationBased-target_name 1154 java-operationBased-java_android_annotations 1151 java-operationBased-java_jsr305_annotations 1151 -java-operationBased-target_name 1150 -kotlin-operationBased-union_inline_fragments 1147 -kotlin-responseBased-union_inline_fragments 1147 java-operationBased-java_guava_optionals 1135 java-operationBased-java_java_optionals 1135 java-operationBased-java_apollo_optionals 1134 kotlin-operationBased-fragment_spread_with_include_directive 1121 -kotlin-operationBased-unique_type_name 1109 -java-operationBased-root_query_inline_fragment 1104 +kotlin-operationBased-unique_type_name 1119 +java-operationBased-root_query_inline_fragment 1108 kotlin-responseBased-fragments_with_type_condition 1102 -kotlin-responseBased-nested_conditional_inline 1085 +kotlin-responseBased-nested_conditional_inline 1095 java-operationBased-java_primitive_types 1077 kotlin-responseBased-multiple_fragments 1074 kotlin-responseBased-named_fragment_with_variables 1067 @@ -69,26 +69,26 @@ kotlin-operationBased-root_query_fragment_with_nested_fragments java-operationBased-fragment_spread_with_nested_fields 1054 kotlin-responseBased-simple_fragment_with_inline_fragments 1052 kotlin-operationBased-simple_fragment 1043 +java-operationBased-inline_fragments_with_friends 1042 java-operationBased-operationbased2_ex8 1042 -java-operationBased-inline_fragments_with_friends 1038 kotlin-operationBased-named_fragment_delegate 1013 java-operationBased-decapitalized_fields 993 java-operationBased-simple_union 975 java-operationBased-fragments_same_type_condition 973 kotlin-responseBased-operationbased2_ex8 961 +kotlin-operationBased-nested_conditional_inline 958 java-operationBased-deprecated_merged_field 950 -kotlin-operationBased-nested_conditional_inline 948 java-operationBased-input_object_oneof 943 java-operationBased-used_arguments 941 java-operationBased-not_all_combinations_are_needed 938 -java-operationBased-hero_details 923 +kotlin-responseBased-mutation_create_review_semantic_naming 928 +java-operationBased-hero_details 927 java-operationBased-simple_inline_fragment 919 -kotlin-responseBased-mutation_create_review_semantic_naming 918 kotlin-operationBased-named_fragment_with_variables 918 java-operationBased-fieldset_with_multiple_super 915 java-operationBased-inline_fragment_with_include_directive 913 +java-operationBased-introspection_query 901 java-operationBased-union_fragment 898 -java-operationBased-introspection_query 897 kotlin-operationBased-fragment_used_twice 893 java-operationBased-inline_fragment_inside_inline_fragment 883 java-operationBased-test_inline 881 @@ -97,34 +97,34 @@ kotlin-operationBased-multiple_fragments kotlin-responseBased-nested_field_with_multiple_fieldsets 844 java-operationBased-named_fragment_without_implementation 840 kotlin-operationBased-fragments_with_type_condition 833 -kotlin-responseBased-target_name 817 +kotlin-responseBased-target_name 827 +kotlin-operationBased-named_fragment_inside_inline_fragment 814 kotlin-operationBased-nested_field_with_multiple_fieldsets 814 kotlin-responseBased-two_heroes_with_friends 808 java-operationBased-fragment_with_multiple_fieldsets 804 -kotlin-operationBased-named_fragment_inside_inline_fragment 804 java-operationBased-hero_details_semantic_naming 803 +kotlin-operationBased-root_query_inline_fragment 803 +kotlin-responseBased-inline_fragments_with_friends 800 kotlin-operationBased-inline_fragment_merge_fields 799 +kotlin-operationBased-target_name 799 java-operationBased-operationbased2_ex7 798 -kotlin-operationBased-root_query_inline_fragment 793 -kotlin-responseBased-inline_fragments_with_friends 790 -kotlin-operationBased-target_name 789 +kotlin-responseBased-named_fragment_inside_inline_fragment 795 kotlin-responseBased-deprecated_merged_field 786 -kotlin-responseBased-named_fragment_inside_inline_fragment 785 -java-operationBased-suppressed_warnings 779 +java-operationBased-suppressed_warnings 783 +kotlin-responseBased-root_query_inline_fragment 779 java-operationBased-path_vs_flat_accessors 776 java-operationBased-reserved_keywords 772 -kotlin-responseBased-root_query_inline_fragment 769 kotlin-responseBased-simple_union 769 java-operationBased-typename_always_first 754 -kotlin-operationBased-inline_fragments_with_friends 739 +kotlin-operationBased-inline_fragments_with_friends 749 kotlin-responseBased-fragments_same_type_condition 738 java-operationBased-interface_on_interface 736 -java-operationBased-input_object_variable_and_argument 718 -java-operationBased-input_object_variable_and_argument_with_generated_methods 718 +java-operationBased-input_object_variable_and_argument 722 +java-operationBased-input_object_variable_and_argument_with_generated_methods 722 java-operationBased-root_query_fragment 717 kotlin-operationBased-simple_fragment_with_inline_fragments 714 kotlin-operationBased-fragment_spread_with_nested_fields 705 -kotlin-responseBased-input_object_variable_and_argument_with_generated_methods 693 +kotlin-responseBased-input_object_variable_and_argument_with_generated_methods 703 java-operationBased-monomorphic 689 kotlin-operationBased-operationbased2_ex8 685 java-operationBased-interface_always_nested 683 @@ -141,54 +141,54 @@ java-operationBased-capitalized_fields kotlin-operationBased-simple_union 665 java-operationBased-recursive_selection 661 kotlin-responseBased-fragment_with_multiple_fieldsets 659 +kotlin-responseBased-hero_details 657 kotlin-responseBased-test_inline 657 +java-operationBased-hero_with_review 652 kotlin-responseBased-named_fragment_without_implementation 651 kotlin-operationBased-used_arguments 651 kotlin-operationBased-union_fragment 650 -java-operationBased-hero_with_review 648 kotlin-operationBased-decapitalized_fields 647 -kotlin-responseBased-hero_details 647 kotlin-operationBased-deprecated_merged_field 646 +java-operationBased-deprecation 645 kotlin-operationBased-inline_fragment_inside_inline_fragment 645 -java-operationBased-deprecation 641 kotlin-responseBased-inline_fragment_inside_inline_fragment 639 java-operationBased-field_with_include_directive 638 java-operationBased-custom_scalar_type 637 kotlin-operationBased-not_all_combinations_are_needed 637 kotlin-responseBased-java_primitive_types 636 kotlin-responseBased-inline_fragment_merge_fields 629 +java-operationBased-hero_name_query_long_name 627 kotlin-operationBased-inline_fragment_with_include_directive 627 java-operationBased-hero_name 626 -java-operationBased-hero_name_query_long_name 623 +kotlin-responseBased-introspection_query 625 +java-operationBased-variable_default_value 624 kotlin-operationBased-fieldset_with_multiple_super 620 -java-operationBased-variable_default_value 620 kotlin-operationBased-simple_inline_fragment 618 kotlin-operationBased-named_fragment_without_implementation 616 kotlin-responseBased-operationbased2_ex7 616 -kotlin-responseBased-introspection_query 615 +kotlin-responseBased-input_object_variable_and_argument 614 java-operationBased-java8annotation 614 kotlin-responseBased-not_all_combinations_are_needed 612 kotlin-responseBased-simple_inline_fragment 611 kotlin-responseBased-decapitalized_fields 610 kotlin-responseBased-fieldset_with_multiple_super 607 -kotlin-responseBased-input_object_variable_and_argument 604 java-operationBased-inline_fragment_for_non_optional_field 602 kotlin-responseBased-reserved_keywords 600 +java-operationBased-optional 593 java-operationBased-two_heroes_unique 591 -java-operationBased-optional 589 java-operationBased-inline_fragment_type_coercion 587 +java-operationBased-enum_field 586 kotlin-operationBased-test_inline 581 -java-operationBased-enum_field 578 java-operationBased-inline_fragment_simple 573 kotlin-operationBased-reserved_keywords 573 -java-operationBased-list_field_clash 558 +java-operationBased-list_field_clash 562 +kotlin-responseBased-hero_with_review 561 kotlin-responseBased-path_vs_flat_accessors 558 -kotlin-responseBased-hero_with_review 551 +kotlin-responseBased-suppressed_warnings 552 kotlin-responseBased-hero_details_semantic_naming 548 kotlin-operationBased-fragment_with_multiple_fieldsets 543 java-operationBased-starships 543 kotlin-responseBased-root_query_fragment 542 -kotlin-responseBased-suppressed_warnings 542 kotlin-responseBased-interface_on_interface 541 kotlin-responseBased-input_object_oneof 539 kotlin-responseBased-typename_always_first 539 @@ -198,37 +198,37 @@ kotlin-operationBased-typename_always_first kotlin-operationBased-path_vs_flat_accessors 527 java-operationBased-antlr_tokens 526 java-operationBased-subscriptions 525 +kotlin-responseBased-hero_name_query_long_name 524 kotlin-operationBased-interface_on_interface 515 -kotlin-responseBased-hero_name_query_long_name 514 kotlin-responseBased-hero_name 512 kotlin-responseBased-interface_always_nested 502 +kotlin-responseBased-variable_default_value 498 kotlin-responseBased-custom_scalar_type 497 +kotlin-responseBased-deprecation 493 kotlin-operationBased-root_query_fragment 491 -kotlin-responseBased-variable_default_value 488 -kotlin-responseBased-deprecation 483 +kotlin-responseBased-enum_field 489 java-operationBased-merged_include 478 java-operationBased-operation_id_generator 478 kotlin-responseBased-inline_fragment_for_non_optional_field 477 kotlin-operationBased-monomorphic 475 kotlin-responseBased-monomorphic 475 kotlin-operationBased-interface_always_nested 474 -kotlin-responseBased-enum_field 469 -kotlin-responseBased-optional 460 +kotlin-responseBased-optional 470 java-operationBased-nonnull 457 kotlin-operationBased-hero_name 455 kotlin-operationBased-capitalized_fields 454 kotlin-responseBased-field_with_include_directive 453 +java-operationBased-enums_as_sealed 451 java-operationBased-companion 449 +java-operationBased-case_sensitive_enum 448 kotlin-responseBased-inline_fragment_type_coercion 448 -java-operationBased-enums_as_sealed 447 -java-operationBased-case_sensitive_enum 444 java-operationBased-object 444 kotlin-responseBased-recursive_selection 439 kotlin-operationBased-inline_fragment_for_non_optional_field 434 kotlin-responseBased-inline_fragment_simple 433 kotlin-responseBased-arguments_hardcoded 429 +kotlin-responseBased-list_field_clash 428 kotlin-responseBased-two_heroes_unique 419 -kotlin-responseBased-list_field_clash 418 kotlin-responseBased-capitalized_fields 416 kotlin-operationBased-inline_fragment_type_coercion 413 kotlin-operationBased-inline_fragment_simple 406 @@ -236,12 +236,12 @@ kotlin-responseBased-starships kotlin-responseBased-java8annotation 403 kotlin-responseBased-antlr_tokens 398 kotlin-responseBased-subscriptions 391 -kotlin-responseBased-enums_as_sealed 364 +kotlin-responseBased-enums_as_sealed 371 +kotlin-responseBased-case_sensitive_enum 352 kotlin-responseBased-operation_id_generator 346 kotlin-responseBased-big_query 344 kotlin-responseBased-merged_include 344 java-operationBased-java_hashcode 343 -kotlin-responseBased-case_sensitive_enum 342 kotlin-responseBased-nonnull 328 kotlin-operationBased-companion 321 kotlin-responseBased-object 319 diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected index 503ccbcd7d8..b8b87a290af 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/java/operationBased/mutation_create_review/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected index bfbc08e09b9..22eb0a37a5f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.mutation_create_review.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ internal enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected index 772e9e817f2..063c66af47b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.mutation_create_review.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.mutation_create_review.type.Episode +import kotlin.OptIn internal object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected index 88a1d7d6a2f..6d6eb3b8e47 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/java/operationBased/mutation_create_review_semantic_naming/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected index dc124b4e44a..2f51c17f141 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.mutation_create_review_semantic_naming.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected index 77b02424791..309602bcd26 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.mutation_create_review_semantic_naming.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.mutation_create_review_semantic_naming.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected index 5cd2379b924..e3edaeb53eb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/java/operationBased/named_fragment_inside_inline_fragment/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 05c17097db2..80fab72b587 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.named_fragment_inside_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index c0a3b56e807..7560db47e4f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.named_fragment_inside_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.named_fragment_inside_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 05c17097db2..80fab72b587 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.named_fragment_inside_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index c0a3b56e807..7560db47e4f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.named_fragment_inside_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.named_fragment_inside_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected index e9c0cdc67ff..7d52a0d0981 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/java/operationBased/nested_conditional_inline/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected index a8636ec63ea..268ab941f2c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.nested_conditional_inline.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected index 1d45b28137a..1866b57e279 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.nested_conditional_inline.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.nested_conditional_inline.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected index a8636ec63ea..268ab941f2c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.nested_conditional_inline.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected index 1d45b28137a..1866b57e279 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.nested_conditional_inline.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.nested_conditional_inline.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected index 20d4dc4138b..b174cc3a003 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/java/operationBased/optional/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected index 370ec8951f1..1f8cf7292ba 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.optional.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected index a6c134955e9..c529a97ed9c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.optional.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.optional.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected index 8d173c1823f..cdb6d742617 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/java/operationBased/root_query_inline_fragment/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected index cf37874373a..e2bdb228ddb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.root_query_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index bc573a99f2a..1a7a13f22fd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.root_query_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.root_query_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected index cf37874373a..e2bdb228ddb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.root_query_inline_fragment.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index bc573a99f2a..1a7a13f22fd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.root_query_inline_fragment.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.root_query_inline_fragment.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected index 1a1d951b1fb..b7939885c2f 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/java/operationBased/suppressed_warnings/type/Direction.java.expected @@ -28,6 +28,10 @@ public class Direction { this.rawValue = rawValue; } + /** + * Returns the Direction that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Direction safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected index 93f7de18aa1..d433a794dce 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected @@ -6,6 +6,7 @@ package com.example.suppressed_warnings.type import com.apollographql.apollo3.annotations.ApolloRequiresOptIn +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -51,6 +52,12 @@ public enum class Direction( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Direction] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Direction = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected index c547f5498cf..91e6fc18e64 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.suppressed_warnings.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.suppressed_warnings.type.Direction +import kotlin.OptIn public object Direction_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Direction { val rawValue = reader.nextString()!! return Direction.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected index 0ef983d3a91..686b79a32f5 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/java/operationBased/target_name/type/renamedEnum.java.expected @@ -23,6 +23,10 @@ public class RenamedEnum { this.rawValue = rawValue; } + /** + * Returns the ReservedEnum that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ public static RenamedEnum safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { case "VALUE": return RenamedEnum.VALUE; diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected index dceaf7f9222..f39971b1e6b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.target_name.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.target_name.type.RenamedEnum +import kotlin.OptIn public object RenamedEnum_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): RenamedEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected index d474a7907b2..e2f345cd9fd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected @@ -5,6 +5,7 @@ // package com.example.target_name.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -40,6 +41,12 @@ public enum class RenamedEnum( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [RenamedEnum] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): RenamedEnum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected index dceaf7f9222..f39971b1e6b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.target_name.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.target_name.type.RenamedEnum +import kotlin.OptIn public object RenamedEnum_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): RenamedEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected index d474a7907b2..e2f345cd9fd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected @@ -5,6 +5,7 @@ // package com.example.target_name.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -40,6 +41,12 @@ public enum class RenamedEnum( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [RenamedEnum] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): RenamedEnum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected index 23d9250a8c3..bd561137530 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/java/operationBased/union_inline_fragments/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected index 3d7dbba159e..9382db946ee 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.union_inline_fragments.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected index 0750e5ab2bc..c0ad49d612c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.union_inline_fragments.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.union_inline_fragments.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected index 3d7dbba159e..9382db946ee 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.union_inline_fragments.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected index 0750e5ab2bc..c0ad49d612c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.union_inline_fragments.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.union_inline_fragments.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected index eb4104d7ca0..b14c92bda7d 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/java/operationBased/unique_type_name/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected index e725a0b8ace..61030563d67 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.unique_type_name.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected index a16d888a696..8e1c9ca77f5 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.unique_type_name.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.unique_type_name.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected index e725a0b8ace..61030563d67 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.unique_type_name.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected index a16d888a696..8e1c9ca77f5 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.unique_type_name.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.unique_type_name.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected index d4457fffeda..54fb688e079 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/java/operationBased/variable_default_value/type/Episode.java.expected @@ -35,6 +35,10 @@ public class Episode { this.rawValue = rawValue; } + /** + * Returns the Episode that represents the specified rawValue. + * Note: unknown values of rawValue will return UNKNOWN__. You may want to update your schema instead of calling this method directly. + */ @SuppressWarnings("deprecation") public static Episode safeValueOf(String rawValue) { switch (Objects.requireNonNull(rawValue)) { diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected index a64f9c51c55..7059dd63cc6 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected @@ -5,6 +5,7 @@ // package com.example.variable_default_value.type +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -71,6 +72,12 @@ public enum class Episode( ) public fun knownValues(): Array = knownEntries.toTypedArray() + /** + * Returns the [Episode] that represents the specified [rawValue]. + * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your + * schema instead of calling this function directly. + */ + @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected index 921c6e207e1..ea73e5b091e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,13 +5,16 @@ // package com.example.variable_default_value.type.adapter +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.variable_default_value.type.Episode +import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { + @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index 39d06bf25d4..061c3eb6bbe 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -1,6 +1,6 @@ package test -import com.apollographql.apollo3.annotations.ApolloEnumConstructor +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import enums.kotlin15.type.Direction import enums.kotlin15.type.Foo import enums.kotlin15.type.FooEnum @@ -14,6 +14,7 @@ import kotlin.test.assertNotEquals class EnumsTest { @Test + @OptIn(ApolloUnknownEnum::class) fun kotlinEnums() { assertEquals(Direction.NORTH, Direction.safeValueOf("NORTH")) @Suppress("DEPRECATION") @@ -27,15 +28,17 @@ class EnumsTest { @Test fun kotlin19Enums() { + @OptIn(ApolloUnknownEnum::class) assertEquals(enums.kotlin19.type.Direction.safeValueOf("NORTH"), enums.kotlin19.type.Direction.NORTH) } @Test + @OptIn(ApolloUnknownEnum::class) fun kotlinSealedClasses() { assertEquals(Gravity.TOP, Gravity.safeValueOf("TOP")) @Suppress("DEPRECATION") assertEquals(Gravity.top2, Gravity.safeValueOf("top2")) - assertEquals(@OptIn(ApolloEnumConstructor::class) Gravity.UNKNOWN__("newGravity"), Gravity.safeValueOf("newGravity")) + assertEquals(Gravity.UNKNOWN__("newGravity"), Gravity.safeValueOf("newGravity")) assertEquals(Gravity.name, Gravity.safeValueOf("name")) assertEquals(Gravity.ordinal, Gravity.safeValueOf("ordinal")) assertEquals(Gravity.type__, Gravity.safeValueOf("type")) @@ -86,6 +89,7 @@ class EnumsTest { } @Test + @OptIn(ApolloUnknownEnum::class) fun type() { assertEquals(Direction.type__, Direction.safeValueOf("type")) assertEquals(Gravity.type__, Gravity.safeValueOf("type")) From 66c969ac1a48d10d1b39788454c4b129a16a5a86 Mon Sep 17 00:00:00 2001 From: BoD Date: Mon, 20 May 2024 10:46:04 +0200 Subject: [PATCH 09/11] Update API dump --- libraries/apollo-annotations/api/apollo-annotations.api | 6 +++--- .../apollo-annotations/api/apollo-annotations.klib.api | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/apollo-annotations/api/apollo-annotations.api b/libraries/apollo-annotations/api/apollo-annotations.api index d0222e2ccd9..93ae6cdcc22 100644 --- a/libraries/apollo-annotations/api/apollo-annotations.api +++ b/libraries/apollo-annotations/api/apollo-annotations.api @@ -27,9 +27,6 @@ public final class com/apollographql/apollo3/annotations/ApolloDeprecatedSince$V public static fun values ()[Lcom/apollographql/apollo3/annotations/ApolloDeprecatedSince$Version; } -public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloEnumConstructor : java/lang/annotation/Annotation { -} - public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloExperimental : java/lang/annotation/Annotation { } @@ -39,6 +36,9 @@ public abstract interface annotation class com/apollographql/apollo3/annotations public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloRequiresOptIn : java/lang/annotation/Annotation { } +public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloUnknownEnum : java/lang/annotation/Annotation { +} + public abstract interface annotation class com/apollographql/apollo3/annotations/GraphQLAdapter : java/lang/annotation/Annotation { public abstract fun forScalar ()Ljava/lang/String; } diff --git a/libraries/apollo-annotations/api/apollo-annotations.klib.api b/libraries/apollo-annotations/api/apollo-annotations.klib.api index de0b77df7d0..5b2c380afbf 100644 --- a/libraries/apollo-annotations/api/apollo-annotations.klib.api +++ b/libraries/apollo-annotations/api/apollo-annotations.klib.api @@ -37,9 +37,6 @@ open annotation class com.apollographql.apollo3.annotations/ApolloDeprecatedSinc final val version // com.apollographql.apollo3.annotations/ApolloDeprecatedSince.version|{}version[0] final fun (): com.apollographql.apollo3.annotations/ApolloDeprecatedSince.Version // com.apollographql.apollo3.annotations/ApolloDeprecatedSince.version.|(){}[0] } -open annotation class com.apollographql.apollo3.annotations/ApolloEnumConstructor : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloEnumConstructor|null[0] - constructor () // com.apollographql.apollo3.annotations/ApolloEnumConstructor.|(){}[0] -} open annotation class com.apollographql.apollo3.annotations/ApolloExperimental : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloExperimental|null[0] constructor () // com.apollographql.apollo3.annotations/ApolloExperimental.|(){}[0] } @@ -49,6 +46,9 @@ open annotation class com.apollographql.apollo3.annotations/ApolloInternal : kot open annotation class com.apollographql.apollo3.annotations/ApolloRequiresOptIn : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloRequiresOptIn|null[0] constructor () // com.apollographql.apollo3.annotations/ApolloRequiresOptIn.|(){}[0] } +open annotation class com.apollographql.apollo3.annotations/ApolloUnknownEnum : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloUnknownEnum|null[0] + constructor () // com.apollographql.apollo3.annotations/ApolloUnknownEnum.|(){}[0] +} open annotation class com.apollographql.apollo3.annotations/GraphQLAdapter : kotlin/Annotation { // com.apollographql.apollo3.annotations/GraphQLAdapter|null[0] constructor (kotlin/String) // com.apollographql.apollo3.annotations/GraphQLAdapter.|(kotlin.String){}[0] final val forScalar // com.apollographql.apollo3.annotations/GraphQLAdapter.forScalar|{}forScalar[0] From bd2291511948200969e9e49b7652d0de18b5d6ac Mon Sep 17 00:00:00 2001 From: BoD Date: Mon, 27 May 2024 16:48:54 +0200 Subject: [PATCH 10/11] Make enums as sealed classes generate sealed interfaces --- .../kotlin/schema/EnumAsSealedBuilder.kt | 53 ++++++++++++------ .../enums_as_sealed/type/Enum.kt.expected | 55 +++++++++++-------- tests/enums/src/test/kotlin/test/EnumsTest.kt | 2 +- .../src/commonTest/kotlin/test/EnumTest.kt | 5 +- 4 files changed, 73 insertions(+), 42 deletions(-) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt index d1dcb52c850..729264d7261 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt @@ -50,16 +50,15 @@ internal class EnumAsSealedBuilder( return CgFile( packageName = packageName, fileName = simpleName, - typeSpecs = listOf(enum.toSealedClassTypeSpec()) + typeSpecs = listOf(enum.toSealedClassTypeSpec(), enum.unknownClassTypeSpec()) ) } private fun IrEnum.toSealedClassTypeSpec(): TypeSpec { - return TypeSpec.classBuilder(simpleName) + return TypeSpec.interfaceBuilder(simpleName) .maybeAddDescription(description) // XXX: can an enum be made deprecated (and not only its values) ? .addModifiers(KModifier.SEALED) - .primaryConstructor(primaryConstructorWithOverriddenParamSpec) .addProperty(rawValuePropertySpec) .addType(companionTypeSpec()) .addTypes(values.map { value -> @@ -82,19 +81,30 @@ internal class EnumAsSealedBuilder( .maybeAddDeprecation(deprecationReason) .maybeAddDescription(description) .maybeAddRequiresOptIn(context.resolver, optInFeature) - .superclass(superClass) - .addSuperclassConstructorParameter("rawValue·=·%S", name) + .addSuperinterface(superClass) + .addProperty( + PropertySpec.builder("rawValue", KotlinSymbols.String) + .addModifiers(KModifier.OVERRIDE) + .initializer("%S", name) + .build() + ) .build() } private fun IrEnum.unknownValueTypeSpec(): TypeSpec { - return TypeSpec.classBuilder("UNKNOWN__") - .addKdoc("An enum value that wasn't known at compile time.\n" + - "Note: the `UNKNOWN__` class represents GraphQL enums that are not present in the schema and whose `rawValue` cannot be checked at build time. You may want to update your schema instead of instantiating it directly." - ) + return TypeSpec.interfaceBuilder("UNKNOWN__") + .addKdoc("An enum value that wasn't known at compile time.") + .addSuperinterface(selfClassName) + .addProperty(unknownValueRawValuePropertySpec) + .build() + } + + private fun IrEnum.unknownClassTypeSpec(): TypeSpec { + return TypeSpec.classBuilder("UNKNOWN__${simpleName}") + .addSuperinterface(unknownValueInterfaceName()) .primaryConstructor(unknownValuePrimaryConstructorSpec) - .superclass(selfClassName) - .addSuperclassConstructorParameter("rawValue·=·rawValue") + .addProperty(unknownValueRawValuePropertySpecWithInitializer) + .addModifiers(KModifier.PRIVATE) .addFunction( FunSpec.builder("equals") .addModifiers(KModifier.OVERRIDE) @@ -139,7 +149,7 @@ internal class EnumAsSealedBuilder( .map { CodeBlock.of("%S·->·%T", it.name, it.valueClassName()) } .joinToCode(separator = "\n", suffix = "\n") ) - .addCode("else -> @OptIn(%T::class) %T(rawValue)\n", KotlinSymbols.ApolloUnknownEnum, unknownValueClassName()) + .addCode("else -> %T(rawValue)\n", unknownValueClassName()) .endControlFlow() .build() } @@ -170,24 +180,31 @@ internal class EnumAsSealedBuilder( return ClassName(selfClassName.packageName, selfClassName.simpleName, targetName.escapeKotlinReservedWordInSealedClass()) } - private fun unknownValueClassName(): ClassName { + private fun unknownValueInterfaceName(): ClassName { return ClassName(selfClassName.packageName, selfClassName.simpleName, "UNKNOWN__") } + private fun unknownValueClassName(): ClassName { + return ClassName(selfClassName.packageName, "UNKNOWN__${selfClassName.simpleName}") + } + private val unknownValuePrimaryConstructorSpec = FunSpec.constructorBuilder() - .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addParameter("rawValue", KotlinSymbols.String) .build() - private val primaryConstructorWithOverriddenParamSpec = - FunSpec.constructorBuilder() - .addParameter("rawValue", KotlinSymbols.String) + private val unknownValueRawValuePropertySpec = + PropertySpec.builder("rawValue", KotlinSymbols.String) + .addModifiers(KModifier.OVERRIDE) .build() - private val rawValuePropertySpec = + private val unknownValueRawValuePropertySpecWithInitializer = PropertySpec.builder("rawValue", KotlinSymbols.String) + .addModifiers(KModifier.OVERRIDE) .initializer("rawValue") .build() + private val rawValuePropertySpec = + PropertySpec.builder("rawValue", KotlinSymbols.String) + .build() } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected index fb4b6b96623..8e5d18fc8f6 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected @@ -15,9 +15,9 @@ import kotlin.Int import kotlin.String import kotlin.Suppress -public sealed class Enum( - public val rawValue: String, -) { +public sealed interface Enum { + public val rawValue: String + public companion object { public val type: EnumType = EnumType("Enum", listOf("north", "North", "NORTH", "SOUTH", "type")) @@ -34,7 +34,7 @@ public sealed class Enum( "NORTH" -> NORTH "SOUTH" -> SOUTH "type" -> type_ - else -> @OptIn(ApolloUnknownEnum::class) UNKNOWN__(rawValue) + else -> UNKNOWN__Enum(rawValue) } /** @@ -50,33 +50,44 @@ public sealed class Enum( } @Deprecated(message = "No longer supported") - public object north : Enum(rawValue = "north") + public object north : Enum { + override val rawValue: String = "north" + } @Deprecated(message = "No longer supported") - public object North : Enum(rawValue = "North") + public object North : Enum { + override val rawValue: String = "North" + } - public object NORTH : Enum(rawValue = "NORTH") + public object NORTH : Enum { + override val rawValue: String = "NORTH" + } - public object SOUTH : Enum(rawValue = "SOUTH") + public object SOUTH : Enum { + override val rawValue: String = "SOUTH" + } - public object type_ : Enum(rawValue = "type") + public object type_ : Enum { + override val rawValue: String = "type" + } /** * An enum value that wasn't known at compile time. - * Note: the `UNKNOWN__` class represents GraphQL enums that are not present in the schema and - * whose `rawValue` cannot be checked at build time. You may want to update your schema instead of - * instantiating it directly. */ - public class UNKNOWN__ @ApolloUnknownEnum constructor( - rawValue: String, - ) : Enum(rawValue = rawValue) { - override fun equals(other: Any?): Boolean { - if (other !is UNKNOWN__) return false - return this.rawValue == other.rawValue - } - - override fun hashCode(): Int = this.rawValue.hashCode() + public interface UNKNOWN__ : Enum { + override val rawValue: String + } +} - override fun toString(): String = "UNKNOWN__($rawValue)" +private class UNKNOWN__Enum( + override val rawValue: String, +) : Enum.UNKNOWN__ { + override fun equals(other: Any?): Boolean { + if (other !is UNKNOWN__Enum) return false + return this.rawValue == other.rawValue } + + override fun hashCode(): Int = this.rawValue.hashCode() + + override fun toString(): String = "UNKNOWN__($rawValue)" } diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index 061c3eb6bbe..ec569519b2e 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -38,7 +38,7 @@ class EnumsTest { assertEquals(Gravity.TOP, Gravity.safeValueOf("TOP")) @Suppress("DEPRECATION") assertEquals(Gravity.top2, Gravity.safeValueOf("top2")) - assertEquals(Gravity.UNKNOWN__("newGravity"), Gravity.safeValueOf("newGravity")) + assertIs(Gravity.safeValueOf("newGravity")) assertEquals(Gravity.name, Gravity.safeValueOf("name")) assertEquals(Gravity.ordinal, Gravity.safeValueOf("ordinal")) assertEquals(Gravity.type__, Gravity.safeValueOf("type")) diff --git a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt index e3cefc44348..c828a778692 100644 --- a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt +++ b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt @@ -1,13 +1,16 @@ package test +import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.integration.normalizer.type.Episode import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.test.assertIs class EnumTest { + @OptIn(ApolloUnknownEnum::class) @Test fun safeValueOf() { assertEquals(Episode.EMPIRE, Episode.safeValueOf("EMPIRE")) - assertEquals(Episode.UNKNOWN__::class, Episode.safeValueOf("NEW_EPISODE")::class) + assertIs(Episode.safeValueOf("NEW_EPISODE")) } } From c493ce70343f54092bfe42e1ae06d58b9522ae2e Mon Sep 17 00:00:00 2001 From: BoD Date: Tue, 28 May 2024 14:09:46 +0200 Subject: [PATCH 11/11] Remove ApolloUnknownEnum --- .../api/apollo-annotations.api | 3 - .../api/apollo-annotations.klib.api | 3 - .../apollo3/annotations/ApolloUnknownEnum.kt | 9 --- .../compiler/codegen/kotlin/KotlinSymbols.kt | 1 - .../kotlin/schema/EnumAsEnumBuilder.kt | 1 - .../kotlin/schema/EnumAsSealedBuilder.kt | 1 - .../schema/EnumResponseAdapterBuilder.kt | 2 - .../case_sensitive_enum/type/Enum.kt.expected | 2 - .../adapter/Enum_ResponseAdapter.kt.expected | 3 - .../deprecation/type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../enum_field/type/Gravity.kt.expected | 2 - .../enum_field/type/GravityAsEnum.kt.expected | 2 - .../GravityAsEnum_ResponseAdapter.kt.expected | 3 - .../Gravity_ResponseAdapter.kt.expected | 3 - .../enums_as_sealed/type/Enum.kt.expected | 2 - .../adapter/Enum_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../hero_type_ResponseAdapter.kt.expected | 3 - .../hero_details/type/hero_type.kt.expected | 2 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../hero_with_review/type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Race.kt.expected | 2 - .../adapter/Race_ResponseAdapter.kt.expected | 3 - .../type/Race.kt.expected | 2 - .../adapter/Race_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/__TypeKind.kt.expected | 2 - .../__TypeKind_ResponseAdapter.kt.expected | 3 - .../type/AmenityCategory.kt.expected | 2 - ...menityCategory_ResponseAdapter.kt.expected | 3 - .../src/test/graphql/com/example/measurements | 76 +++++++++---------- .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../optional/type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Direction.kt.expected | 2 - .../Direction_ResponseAdapter.kt.expected | 3 - .../renamedEnum_ResponseAdapter.kt.expected | 3 - .../target_name/type/renamedEnum.kt.expected | 2 - .../renamedEnum_ResponseAdapter.kt.expected | 3 - .../target_name/type/renamedEnum.kt.expected | 2 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../unique_type_name/type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../unique_type_name/type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - .../type/Episode.kt.expected | 2 - .../Episode_ResponseAdapter.kt.expected | 3 - tests/enums/src/test/kotlin/test/EnumsTest.kt | 5 -- .../src/commonTest/kotlin/test/EnumTest.kt | 2 - 82 files changed, 38 insertions(+), 245 deletions(-) delete mode 100644 libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt diff --git a/libraries/apollo-annotations/api/apollo-annotations.api b/libraries/apollo-annotations/api/apollo-annotations.api index 93ae6cdcc22..36ce888ee3c 100644 --- a/libraries/apollo-annotations/api/apollo-annotations.api +++ b/libraries/apollo-annotations/api/apollo-annotations.api @@ -36,9 +36,6 @@ public abstract interface annotation class com/apollographql/apollo3/annotations public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloRequiresOptIn : java/lang/annotation/Annotation { } -public abstract interface annotation class com/apollographql/apollo3/annotations/ApolloUnknownEnum : java/lang/annotation/Annotation { -} - public abstract interface annotation class com/apollographql/apollo3/annotations/GraphQLAdapter : java/lang/annotation/Annotation { public abstract fun forScalar ()Ljava/lang/String; } diff --git a/libraries/apollo-annotations/api/apollo-annotations.klib.api b/libraries/apollo-annotations/api/apollo-annotations.klib.api index 5b2c380afbf..586be351c62 100644 --- a/libraries/apollo-annotations/api/apollo-annotations.klib.api +++ b/libraries/apollo-annotations/api/apollo-annotations.klib.api @@ -46,9 +46,6 @@ open annotation class com.apollographql.apollo3.annotations/ApolloInternal : kot open annotation class com.apollographql.apollo3.annotations/ApolloRequiresOptIn : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloRequiresOptIn|null[0] constructor () // com.apollographql.apollo3.annotations/ApolloRequiresOptIn.|(){}[0] } -open annotation class com.apollographql.apollo3.annotations/ApolloUnknownEnum : kotlin/Annotation { // com.apollographql.apollo3.annotations/ApolloUnknownEnum|null[0] - constructor () // com.apollographql.apollo3.annotations/ApolloUnknownEnum.|(){}[0] -} open annotation class com.apollographql.apollo3.annotations/GraphQLAdapter : kotlin/Annotation { // com.apollographql.apollo3.annotations/GraphQLAdapter|null[0] constructor (kotlin/String) // com.apollographql.apollo3.annotations/GraphQLAdapter.|(kotlin.String){}[0] final val forScalar // com.apollographql.apollo3.annotations/GraphQLAdapter.forScalar|{}forScalar[0] diff --git a/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt b/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt deleted file mode 100644 index f0e79111260..00000000000 --- a/libraries/apollo-annotations/src/commonMain/kotlin/com/apollographql/apollo3/annotations/ApolloUnknownEnum.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.apollographql.apollo3.annotations - -@RequiresOptIn( - level = RequiresOptIn.Level.WARNING, - message = "The `UNKNOWN__` class represents GraphQL enums that are not present in the schema and whose `rawValue` cannot be checked at build time. You may want to update your schema instead of calling this directly." -) -@Retention(AnnotationRetention.BINARY) -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR) -annotation class ApolloUnknownEnum diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt index 2d40dfb7f34..adb33870e98 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinSymbols.kt @@ -105,7 +105,6 @@ internal object KotlinSymbols { val ApolloAdaptableWith = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloAdaptableWith") val ApolloExperimental = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloExperimental") - val ApolloUnknownEnum = ClassName(ClassNames.apolloAnnotationsPackageName, "ApolloUnknownEnum") val JsExport = ClassName("kotlin.js", "JsExport") diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt index e73087bfca7..497c800d895 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsEnumBuilder.kt @@ -128,7 +128,6 @@ internal class EnumAsEnumBuilder( "Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your schema instead of calling this function directly.\n", selfClassName ) - .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addParameter("rawValue", String:: class) .returns(selfClassName) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt index 729264d7261..b07379ddcce 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumAsSealedBuilder.kt @@ -138,7 +138,6 @@ internal class EnumAsSealedBuilder( "Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your schema instead of calling this function directly.\n", selfClassName ) - .addAnnotation(KotlinSymbols.ApolloUnknownEnum) .addSuppressions(enum.values.any { it.deprecationReason != null }) .maybeAddOptIn(context.resolver, enum.values) .addParameter("rawValue", KotlinSymbols.String) diff --git a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt index d7ffacb170f..6d346dd0eb5 100644 --- a/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt +++ b/libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/schema/EnumResponseAdapterBuilder.kt @@ -5,7 +5,6 @@ import com.apollographql.apollo3.compiler.codegen.kotlin.CgFile import com.apollographql.apollo3.compiler.codegen.kotlin.CgFileBuilder import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSchemaContext import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols -import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.requiresOptInAnnotation import com.apollographql.apollo3.compiler.codegen.responseAdapter import com.apollographql.apollo3.compiler.codegen.typeAdapterPackageName import com.apollographql.apollo3.compiler.ir.IrEnum @@ -43,7 +42,6 @@ internal class EnumResponseAdapterBuilder( private fun IrEnum.typeSpec(): TypeSpec { val adaptedTypeName = context.resolver.resolveSchemaType(enum.name) val fromResponseFunSpec = FunSpec.builder(Identifier.fromJson) - .addAnnotation(requiresOptInAnnotation(KotlinSymbols.ApolloUnknownEnum)) .addModifiers(KModifier.OVERRIDE) .addParameter(Identifier.reader, KotlinSymbols.JsonReader) .addParameter(Identifier.customScalarAdapters, KotlinSymbols.CustomScalarAdapters) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected index 3e8c0f889f4..545358ff13c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/Enum.kt.expected @@ -5,7 +5,6 @@ // package com.example.case_sensitive_enum.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -56,7 +55,6 @@ public enum class Enum( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Enum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected index 3d5b7e314d6..c27ae2a899a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/type/adapter/Enum_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.case_sensitive_enum.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.case_sensitive_enum.type.Enum -import kotlin.OptIn public object Enum_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Enum { val rawValue = reader.nextString()!! return Enum.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected index adaa92d4b02..2f7674c2f41 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.deprecation.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -51,7 +50,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected index 9b6850881ff..2329202a48d 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.deprecation.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.deprecation.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected index 02457891253..375a20a3c40 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/Gravity.kt.expected @@ -5,7 +5,6 @@ // package com.example.enum_field.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -61,7 +60,6 @@ public enum class Gravity( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: kotlin.String): Gravity = entries.find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected index 7c7a42fba53..04953d73ab9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/GravityAsEnum.kt.expected @@ -5,7 +5,6 @@ // package com.example.enum_field.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -75,7 +74,6 @@ public enum class GravityAsEnum( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: kotlin.String): GravityAsEnum = entries.find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected index 34fb1307db7..dfba59ad652 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/GravityAsEnum_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.enum_field.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enum_field.type.GravityAsEnum -import kotlin.OptIn public object GravityAsEnum_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): GravityAsEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected index 080c8dbb85a..c7ed21c7b8e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enum_field/kotlin/responseBased/enum_field/type/adapter/Gravity_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.enum_field.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enum_field.type.Gravity -import kotlin.OptIn public object Gravity_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Gravity { val rawValue = reader.nextString()!! return Gravity.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected index 8e5d18fc8f6..e01dbd09ef5 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/Enum.kt.expected @@ -5,7 +5,6 @@ // package com.example.enums_as_sealed.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Any import kotlin.Array @@ -26,7 +25,6 @@ public sealed interface Enum { * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum @Suppress("DEPRECATION") public fun safeValueOf(rawValue: String): Enum = when(rawValue) { "north" -> north diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected index 8b786a31910..dafc0f9522b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/type/adapter/Enum_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.enums_as_sealed.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.enums_as_sealed.type.Enum -import kotlin.OptIn public object Enum_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Enum { val rawValue = reader.nextString()!! return Enum.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected index 589d578b016..72186515573 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.fragment_with_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index d4c20e64f05..5bf34cfdf86 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.fragment_with_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.fragment_with_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected index 589d578b016..72186515573 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.fragment_with_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index d4c20e64f05..5bf34cfdf86 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.fragment_with_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.fragment_with_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected index af55b6fd5e1..9e9d952afab 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/adapter/hero_type_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.hero_details.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_details.type.Hero_type -import kotlin.OptIn public object Hero_type_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Hero_type { val rawValue = reader.nextString()!! return Hero_type.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected index 3776fd65dbf..10c01a9daf7 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_details/kotlin/responseBased/hero_details/type/hero_type.kt.expected @@ -5,7 +5,6 @@ // package com.example.hero_details.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -51,7 +50,6 @@ public enum class Hero_type( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Hero_type = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected index 5cdddf21c20..bf470efda6c 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.hero_name_query_long_name.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected index eb0ef4a5c2e..511cfdb115e 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.hero_name_query_long_name.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_name_query_long_name.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected index e4b9a539ae3..83d113c0abf 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.hero_with_review.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected index 3854c15fb8b..26ed8c1b542 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.hero_with_review.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.hero_with_review.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected index 4caa331a3c0..0c007889015 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/Race.kt.expected @@ -5,7 +5,6 @@ // package com.example.inline_fragment_intersection.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -50,7 +49,6 @@ public enum class Race( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Race = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected index b80342c5f7d..31cdbe28745 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/operationBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.inline_fragment_intersection.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragment_intersection.type.Race -import kotlin.OptIn public object Race_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Race { val rawValue = reader.nextString()!! return Race.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected index 4caa331a3c0..0c007889015 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/Race.kt.expected @@ -5,7 +5,6 @@ // package com.example.inline_fragment_intersection.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -50,7 +49,6 @@ public enum class Race( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Race = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected index b80342c5f7d..31cdbe28745 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragment_intersection/kotlin/responseBased/inline_fragment_intersection/type/adapter/Race_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.inline_fragment_intersection.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragment_intersection.type.Race -import kotlin.OptIn public object Race_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Race { val rawValue = reader.nextString()!! return Race.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected index 99734f67bde..4dbce125c90 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.inline_fragments_with_friends.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected index 1866e8a8771..7b7fadaa606 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.inline_fragments_with_friends.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragments_with_friends.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected index 99734f67bde..4dbce125c90 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.inline_fragments_with_friends.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected index 1866e8a8771..7b7fadaa606 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.inline_fragments_with_friends.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.inline_fragments_with_friends.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected index 915a978488b..dda92079a63 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.input_object_type.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected index b397ab531f9..50f4abec08b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.input_object_type.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_type.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected index 9c15136d31a..fb0c3790b22 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.input_object_variable_and_argument.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected index 7e9a662473e..eaeb2b49213 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.input_object_variable_and_argument.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_variable_and_argument.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected index b539206b754..6b697e86b5a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.input_object_variable_and_argument_with_generated_methods.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected index 42be5a07863..9c688f79ee3 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument_with_generated_methods/kotlin/responseBased/input_object_variable_and_argument_with_generated_methods/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.input_object_variable_and_argument_with_generated_methods.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.input_object_variable_and_argument_with_generated_methods.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected index 361eeae6ca9..eaa4b0c20de 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/__TypeKind.kt.expected @@ -5,7 +5,6 @@ // package com.example.introspection_query.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -61,7 +60,6 @@ public enum class __TypeKind( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): __TypeKind = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected index d129ee74482..4d6c04c8831 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/introspection_query/kotlin/responseBased/introspection_query/type/adapter/__TypeKind_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.introspection_query.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.introspection_query.type.__TypeKind -import kotlin.OptIn public object __TypeKind_ResponseAdapter : Adapter<__TypeKind> { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): __TypeKind { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected index e770ef314a3..d3d26b091b4 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/AmenityCategory.kt.expected @@ -5,7 +5,6 @@ // package com.example.list_field_clash.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -48,7 +47,6 @@ public enum class AmenityCategory( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): AmenityCategory = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected index 794f3598956..161957161fb 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/list_field_clash/kotlin/responseBased/list_field_clash/type/adapter/AmenityCategory_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.list_field_clash.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.list_field_clash.type.AmenityCategory -import kotlin.OptIn public object AmenityCategory_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): AmenityCategory { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/measurements b/libraries/apollo-compiler/src/test/graphql/com/example/measurements index 60eae506a9b..c2dcd19146a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/measurements +++ b/libraries/apollo-compiler/src/test/graphql/com/example/measurements @@ -2,16 +2,16 @@ // If you updated the codegen and test fixtures, you should commit this file too. Test: Total LOC: -aggregate-all 204877 -aggregate-kotlin-responseBased 66062 -aggregate-kotlin-operationBased 42498 +aggregate-all 204708 +aggregate-kotlin-responseBased 65938 +aggregate-kotlin-operationBased 42453 aggregate-kotlin-compat 0 aggregate-java-operationBased 96317 java-operationBased-fragments_with_defer_and_include_directives 5600 kotlin-operationBased-fragments_with_defer_and_include_directives 3488 java-operationBased-data_builders 3031 -kotlin-responseBased-fragment_with_inline_fragment 2432 +kotlin-responseBased-fragment_with_inline_fragment 2427 java-operationBased-mutation_create_review 2421 kotlin-responseBased-data_builders 2355 java-operationBased-fragment_with_inline_fragment 2247 @@ -27,40 +27,40 @@ java-operationBased-root_query_fragment_with_nested_fragments java-operationBased-mutation_create_review_semantic_naming 1595 java-operationBased-simple_fragment 1505 java-operationBased-named_fragment_delegate 1493 -kotlin-responseBased-mutation_create_review 1464 +kotlin-responseBased-mutation_create_review 1459 java-operationBased-named_fragment_with_variables 1405 kotlin-responseBased-named_fragment_delegate 1371 -kotlin-responseBased-unique_type_name 1364 +kotlin-responseBased-unique_type_name 1359 java-operationBased-nested_conditional_inline 1330 -kotlin-operationBased-fragment_with_inline_fragment 1307 java-operationBased-fragment_used_twice 1305 +kotlin-operationBased-fragment_with_inline_fragment 1302 java-operationBased-multiple_fragments 1294 -kotlin-responseBased-input_object_type 1288 kotlin-responseBased-root_query_fragment_with_nested_fragments 1287 +kotlin-responseBased-input_object_type 1283 java-operationBased-nested_field_with_multiple_fieldsets 1271 kotlin-operationBased-nested_named_fragments 1269 -kotlin-responseBased-inline_fragment_intersection 1255 +kotlin-responseBased-inline_fragment_intersection 1250 java-operationBased-two_heroes_with_friends 1241 java-operationBased-inline_fragment_merge_fields 1229 kotlin-responseBased-simple_fragment 1195 java-operationBased-fragments_with_type_condition 1183 java-operationBased-named_fragment_inside_inline_fragment 1172 -kotlin-operationBased-inline_fragment_intersection 1164 +kotlin-operationBased-inline_fragment_intersection 1159 kotlin-responseBased-fragment_used_twice 1157 -kotlin-operationBased-union_inline_fragments 1157 -kotlin-responseBased-union_inline_fragments 1157 java-operationBased-java_jetbrains_annotations 1154 java-operationBased-target_name 1154 +kotlin-operationBased-union_inline_fragments 1152 +kotlin-responseBased-union_inline_fragments 1152 java-operationBased-java_android_annotations 1151 java-operationBased-java_jsr305_annotations 1151 java-operationBased-java_guava_optionals 1135 java-operationBased-java_java_optionals 1135 java-operationBased-java_apollo_optionals 1134 kotlin-operationBased-fragment_spread_with_include_directive 1121 -kotlin-operationBased-unique_type_name 1119 +kotlin-operationBased-unique_type_name 1114 java-operationBased-root_query_inline_fragment 1108 kotlin-responseBased-fragments_with_type_condition 1102 -kotlin-responseBased-nested_conditional_inline 1095 +kotlin-responseBased-nested_conditional_inline 1090 java-operationBased-java_primitive_types 1077 kotlin-responseBased-multiple_fragments 1074 kotlin-responseBased-named_fragment_with_variables 1067 @@ -76,13 +76,13 @@ java-operationBased-decapitalized_fields java-operationBased-simple_union 975 java-operationBased-fragments_same_type_condition 973 kotlin-responseBased-operationbased2_ex8 961 -kotlin-operationBased-nested_conditional_inline 958 +kotlin-operationBased-nested_conditional_inline 953 java-operationBased-deprecated_merged_field 950 java-operationBased-input_object_oneof 943 java-operationBased-used_arguments 941 java-operationBased-not_all_combinations_are_needed 938 -kotlin-responseBased-mutation_create_review_semantic_naming 928 java-operationBased-hero_details 927 +kotlin-responseBased-mutation_create_review_semantic_naming 923 java-operationBased-simple_inline_fragment 919 kotlin-operationBased-named_fragment_with_variables 918 java-operationBased-fieldset_with_multiple_super 915 @@ -97,26 +97,26 @@ kotlin-operationBased-multiple_fragments kotlin-responseBased-nested_field_with_multiple_fieldsets 844 java-operationBased-named_fragment_without_implementation 840 kotlin-operationBased-fragments_with_type_condition 833 -kotlin-responseBased-target_name 827 -kotlin-operationBased-named_fragment_inside_inline_fragment 814 +kotlin-responseBased-target_name 822 kotlin-operationBased-nested_field_with_multiple_fieldsets 814 +kotlin-operationBased-named_fragment_inside_inline_fragment 809 kotlin-responseBased-two_heroes_with_friends 808 java-operationBased-fragment_with_multiple_fieldsets 804 java-operationBased-hero_details_semantic_naming 803 -kotlin-operationBased-root_query_inline_fragment 803 -kotlin-responseBased-inline_fragments_with_friends 800 kotlin-operationBased-inline_fragment_merge_fields 799 -kotlin-operationBased-target_name 799 java-operationBased-operationbased2_ex7 798 -kotlin-responseBased-named_fragment_inside_inline_fragment 795 +kotlin-operationBased-root_query_inline_fragment 798 +kotlin-responseBased-inline_fragments_with_friends 795 +kotlin-operationBased-target_name 794 +kotlin-responseBased-named_fragment_inside_inline_fragment 790 kotlin-responseBased-deprecated_merged_field 786 java-operationBased-suppressed_warnings 783 -kotlin-responseBased-root_query_inline_fragment 779 java-operationBased-path_vs_flat_accessors 776 +kotlin-responseBased-root_query_inline_fragment 774 java-operationBased-reserved_keywords 772 kotlin-responseBased-simple_union 769 java-operationBased-typename_always_first 754 -kotlin-operationBased-inline_fragments_with_friends 749 +kotlin-operationBased-inline_fragments_with_friends 744 kotlin-responseBased-fragments_same_type_condition 738 java-operationBased-interface_on_interface 736 java-operationBased-input_object_variable_and_argument 722 @@ -124,7 +124,7 @@ java-operationBased-input_object_variable_and_argument_with_generated_methods java-operationBased-root_query_fragment 717 kotlin-operationBased-simple_fragment_with_inline_fragments 714 kotlin-operationBased-fragment_spread_with_nested_fields 705 -kotlin-responseBased-input_object_variable_and_argument_with_generated_methods 703 +kotlin-responseBased-input_object_variable_and_argument_with_generated_methods 698 java-operationBased-monomorphic 689 kotlin-operationBased-operationbased2_ex8 685 java-operationBased-interface_always_nested 683 @@ -141,8 +141,8 @@ java-operationBased-capitalized_fields kotlin-operationBased-simple_union 665 java-operationBased-recursive_selection 661 kotlin-responseBased-fragment_with_multiple_fieldsets 659 -kotlin-responseBased-hero_details 657 kotlin-responseBased-test_inline 657 +kotlin-responseBased-hero_details 652 java-operationBased-hero_with_review 652 kotlin-responseBased-named_fragment_without_implementation 651 kotlin-operationBased-used_arguments 651 @@ -160,17 +160,17 @@ kotlin-responseBased-inline_fragment_merge_fields java-operationBased-hero_name_query_long_name 627 kotlin-operationBased-inline_fragment_with_include_directive 627 java-operationBased-hero_name 626 -kotlin-responseBased-introspection_query 625 java-operationBased-variable_default_value 624 kotlin-operationBased-fieldset_with_multiple_super 620 +kotlin-responseBased-introspection_query 620 kotlin-operationBased-simple_inline_fragment 618 kotlin-operationBased-named_fragment_without_implementation 616 kotlin-responseBased-operationbased2_ex7 616 -kotlin-responseBased-input_object_variable_and_argument 614 java-operationBased-java8annotation 614 kotlin-responseBased-not_all_combinations_are_needed 612 kotlin-responseBased-simple_inline_fragment 611 kotlin-responseBased-decapitalized_fields 610 +kotlin-responseBased-input_object_variable_and_argument 609 kotlin-responseBased-fieldset_with_multiple_super 607 java-operationBased-inline_fragment_for_non_optional_field 602 kotlin-responseBased-reserved_keywords 600 @@ -182,10 +182,10 @@ kotlin-operationBased-test_inline java-operationBased-inline_fragment_simple 573 kotlin-operationBased-reserved_keywords 573 java-operationBased-list_field_clash 562 -kotlin-responseBased-hero_with_review 561 kotlin-responseBased-path_vs_flat_accessors 558 -kotlin-responseBased-suppressed_warnings 552 +kotlin-responseBased-hero_with_review 556 kotlin-responseBased-hero_details_semantic_naming 548 +kotlin-responseBased-suppressed_warnings 547 kotlin-operationBased-fragment_with_multiple_fieldsets 543 java-operationBased-starships 543 kotlin-responseBased-root_query_fragment 542 @@ -198,22 +198,22 @@ kotlin-operationBased-typename_always_first kotlin-operationBased-path_vs_flat_accessors 527 java-operationBased-antlr_tokens 526 java-operationBased-subscriptions 525 -kotlin-responseBased-hero_name_query_long_name 524 +kotlin-responseBased-hero_name_query_long_name 519 kotlin-operationBased-interface_on_interface 515 kotlin-responseBased-hero_name 512 kotlin-responseBased-interface_always_nested 502 -kotlin-responseBased-variable_default_value 498 kotlin-responseBased-custom_scalar_type 497 -kotlin-responseBased-deprecation 493 +kotlin-responseBased-variable_default_value 493 kotlin-operationBased-root_query_fragment 491 -kotlin-responseBased-enum_field 489 +kotlin-responseBased-deprecation 488 +kotlin-responseBased-enum_field 479 java-operationBased-merged_include 478 java-operationBased-operation_id_generator 478 kotlin-responseBased-inline_fragment_for_non_optional_field 477 kotlin-operationBased-monomorphic 475 kotlin-responseBased-monomorphic 475 kotlin-operationBased-interface_always_nested 474 -kotlin-responseBased-optional 470 +kotlin-responseBased-optional 465 java-operationBased-nonnull 457 kotlin-operationBased-hero_name 455 kotlin-operationBased-capitalized_fields 454 @@ -227,7 +227,7 @@ kotlin-responseBased-recursive_selection kotlin-operationBased-inline_fragment_for_non_optional_field 434 kotlin-responseBased-inline_fragment_simple 433 kotlin-responseBased-arguments_hardcoded 429 -kotlin-responseBased-list_field_clash 428 +kotlin-responseBased-list_field_clash 423 kotlin-responseBased-two_heroes_unique 419 kotlin-responseBased-capitalized_fields 416 kotlin-operationBased-inline_fragment_type_coercion 413 @@ -236,8 +236,8 @@ kotlin-responseBased-starships kotlin-responseBased-java8annotation 403 kotlin-responseBased-antlr_tokens 398 kotlin-responseBased-subscriptions 391 -kotlin-responseBased-enums_as_sealed 371 -kotlin-responseBased-case_sensitive_enum 352 +kotlin-responseBased-enums_as_sealed 377 +kotlin-responseBased-case_sensitive_enum 347 kotlin-responseBased-operation_id_generator 346 kotlin-responseBased-big_query 344 kotlin-responseBased-merged_include 344 diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected index 22eb0a37a5f..7f31bf51849 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.mutation_create_review.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ internal enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected index 063c66af47b..772e9e817f2 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.mutation_create_review.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.mutation_create_review.type.Episode -import kotlin.OptIn internal object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected index 2f51c17f141..635cb849fb9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.mutation_create_review_semantic_naming.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected index 309602bcd26..77b02424791 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.mutation_create_review_semantic_naming.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.mutation_create_review_semantic_naming.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 80fab72b587..a7cd53c9b50 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.named_fragment_inside_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 7560db47e4f..c0a3b56e807 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.named_fragment_inside_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.named_fragment_inside_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 80fab72b587..a7cd53c9b50 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.named_fragment_inside_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 7560db47e4f..c0a3b56e807 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.named_fragment_inside_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.named_fragment_inside_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected index 268ab941f2c..ccca391cf02 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.nested_conditional_inline.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected index 1866b57e279..1d45b28137a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.nested_conditional_inline.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.nested_conditional_inline.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected index 268ab941f2c..ccca391cf02 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.nested_conditional_inline.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected index 1866b57e279..1d45b28137a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.nested_conditional_inline.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.nested_conditional_inline.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected index 1f8cf7292ba..d8e23dc27a9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.optional.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected index c529a97ed9c..a6c134955e9 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.optional.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.optional.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected index e2bdb228ddb..caf879bf6dd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.root_query_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 1a7a13f22fd..bc573a99f2a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.root_query_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.root_query_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected index e2bdb228ddb..caf879bf6dd 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.root_query_inline_fragment.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected index 1a7a13f22fd..bc573a99f2a 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.root_query_inline_fragment.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.root_query_inline_fragment.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected index d433a794dce..01eb9589f49 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/Direction.kt.expected @@ -6,7 +6,6 @@ package com.example.suppressed_warnings.type import com.apollographql.apollo3.annotations.ApolloRequiresOptIn -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -57,7 +56,6 @@ public enum class Direction( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Direction = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected index 91e6fc18e64..c547f5498cf 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/suppressed_warnings/kotlin/responseBased/suppressed_warnings/type/adapter/Direction_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.suppressed_warnings.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.suppressed_warnings.type.Direction -import kotlin.OptIn public object Direction_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Direction { val rawValue = reader.nextString()!! return Direction.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected index f39971b1e6b..dceaf7f9222 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.target_name.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.target_name.type.RenamedEnum -import kotlin.OptIn public object RenamedEnum_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): RenamedEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected index e2f345cd9fd..b54cae02646 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/operationBased/target_name/type/renamedEnum.kt.expected @@ -5,7 +5,6 @@ // package com.example.target_name.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -46,7 +45,6 @@ public enum class RenamedEnum( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): RenamedEnum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected index f39971b1e6b..dceaf7f9222 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/adapter/renamedEnum_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.target_name.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.target_name.type.RenamedEnum -import kotlin.OptIn public object RenamedEnum_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): RenamedEnum { val rawValue = reader.nextString()!! diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected index e2f345cd9fd..b54cae02646 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/target_name/kotlin/responseBased/target_name/type/renamedEnum.kt.expected @@ -5,7 +5,6 @@ // package com.example.target_name.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -46,7 +45,6 @@ public enum class RenamedEnum( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): RenamedEnum = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected index 9382db946ee..19ebdf4be6b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.union_inline_fragments.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected index c0ad49d612c..0750e5ab2bc 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.union_inline_fragments.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.union_inline_fragments.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected index 9382db946ee..19ebdf4be6b 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.union_inline_fragments.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected index c0ad49d612c..0750e5ab2bc 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.union_inline_fragments.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.union_inline_fragments.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected index 61030563d67..95f92c82d37 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.unique_type_name.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected index 8e1c9ca77f5..a16d888a696 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.unique_type_name.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.unique_type_name.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected index 61030563d67..95f92c82d37 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.unique_type_name.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected index 8e1c9ca77f5..a16d888a696 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.unique_type_name.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.unique_type_name.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected index 7059dd63cc6..cbdebe68c53 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected @@ -5,7 +5,6 @@ // package com.example.variable_default_value.type -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.EnumType import kotlin.Array import kotlin.Deprecated @@ -77,7 +76,6 @@ public enum class Episode( * Note: unknown values of [rawValue] will return [UNKNOWN__]. You may want to update your * schema instead of calling this function directly. */ - @ApolloUnknownEnum public fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: UNKNOWN__ } diff --git a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected index ea73e5b091e..921c6e207e1 100644 --- a/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected +++ b/libraries/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/adapter/Episode_ResponseAdapter.kt.expected @@ -5,16 +5,13 @@ // package com.example.variable_default_value.type.adapter -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.json.JsonReader import com.apollographql.apollo3.api.json.JsonWriter import com.example.variable_default_value.type.Episode -import kotlin.OptIn public object Episode_ResponseAdapter : Adapter { - @OptIn(ApolloUnknownEnum::class) override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Episode { val rawValue = reader.nextString()!! return Episode.safeValueOf(rawValue) diff --git a/tests/enums/src/test/kotlin/test/EnumsTest.kt b/tests/enums/src/test/kotlin/test/EnumsTest.kt index ec569519b2e..7c1077da4f2 100644 --- a/tests/enums/src/test/kotlin/test/EnumsTest.kt +++ b/tests/enums/src/test/kotlin/test/EnumsTest.kt @@ -1,6 +1,5 @@ package test -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import enums.kotlin15.type.Direction import enums.kotlin15.type.Foo import enums.kotlin15.type.FooEnum @@ -14,7 +13,6 @@ import kotlin.test.assertNotEquals class EnumsTest { @Test - @OptIn(ApolloUnknownEnum::class) fun kotlinEnums() { assertEquals(Direction.NORTH, Direction.safeValueOf("NORTH")) @Suppress("DEPRECATION") @@ -28,12 +26,10 @@ class EnumsTest { @Test fun kotlin19Enums() { - @OptIn(ApolloUnknownEnum::class) assertEquals(enums.kotlin19.type.Direction.safeValueOf("NORTH"), enums.kotlin19.type.Direction.NORTH) } @Test - @OptIn(ApolloUnknownEnum::class) fun kotlinSealedClasses() { assertEquals(Gravity.TOP, Gravity.safeValueOf("TOP")) @Suppress("DEPRECATION") @@ -89,7 +85,6 @@ class EnumsTest { } @Test - @OptIn(ApolloUnknownEnum::class) fun type() { assertEquals(Direction.type__, Direction.safeValueOf("type")) assertEquals(Gravity.type__, Gravity.safeValueOf("type")) diff --git a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt index c828a778692..e9c203c2103 100644 --- a/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt +++ b/tests/integration-tests/src/commonTest/kotlin/test/EnumTest.kt @@ -1,13 +1,11 @@ package test -import com.apollographql.apollo3.annotations.ApolloUnknownEnum import com.apollographql.apollo3.integration.normalizer.type.Episode import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertIs class EnumTest { - @OptIn(ApolloUnknownEnum::class) @Test fun safeValueOf() { assertEquals(Episode.EMPIRE, Episode.safeValueOf("EMPIRE"))