From b892a605f3bb87595a4d8dd5b6cb43cfb08fde2e Mon Sep 17 00:00:00 2001 From: BoD Date: Tue, 30 Nov 2021 17:38:28 +0100 Subject: [PATCH 1/7] Split CodegenLayout in 2 (Java/Kotlin) to escape reserved keywords depending on codegen language --- .../apollo3/compiler/ReservedKeywords.kt | 15 +- .../compiler/codegen/java/JavaCodeGen.kt | 8 +- .../codegen/java/JavaCodegenLayout.kt | 129 +++++ .../compiler/codegen/java/JavaContext.kt | 8 +- .../codegen/java/model/ModelBuilder.kt | 4 +- .../compiler/codegen/kotlin/KotlinCodeGen.kt | 3 +- .../KotlinCodegenLayout.kt} | 8 +- .../compiler/codegen/kotlin/KotlinContext.kt | 3 +- .../kotlin/file/TestBuildersBuilder.kt | 8 +- .../codegen/kotlin/model/ModelBuilder.kt | 2 +- .../ir/OperationBasedModelGroupBuilder.kt | 6 +- .../ir/ResponseBasedModelGroupBuilder.kt | 6 +- .../__schema/type/Episode.kt.expected | 2 +- .../case_sensitive_enum/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../deprecation/type/Episode.kt.expected | 2 +- .../enums_as_sealed/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../hero_with_review/type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../src/test/graphql/com/example/measurements | 460 +++++++++--------- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../optional/type/Episode.kt.expected | 2 +- .../TestQuery.java.expected | 24 +- .../TestQuery_ResponseAdapter.java.expected | 18 +- .../TestQuerySelections.java.expected | 4 +- .../TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../unique_type_name/type/Episode.kt.expected | 2 +- .../unique_type_name/type/Episode.kt.expected | 2 +- .../unique_type_name/type/Episode.kt.expected | 2 +- .../type/Episode.kt.expected | 2 +- .../src/test/kotlin/test/CustomScalarTest.kt | 6 +- 58 files changed, 475 insertions(+), 349 deletions(-) create mode 100644 apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt rename apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/{CodegenLayout.kt => kotlin/KotlinCodegenLayout.kt} (98%) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt index cc3600fff11..258c918996e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt @@ -1,5 +1,7 @@ package com.apollographql.apollo3.compiler +// Reference: +// https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html private val JAVA_RESERVED_WORDS = arrayOf( "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", @@ -8,15 +10,20 @@ private val JAVA_RESERVED_WORDS = arrayOf( "transient", "try", "true", "void", "volatile", "while" ) +// Reference: +// https://kotlinlang.org/docs/keyword-reference.html#operators-and-special-symbols +// Note: "yield" is not in this reference, but is in fact reserved (https://github.com/apollographql/apollo-android/issues/1957) private val KOTLIN_RESERVED_WORDS = arrayOf( "as", "break", "class", "continue", "do", "else", "false", "for", "fun", "if", "in", "interface", "is", "null", "object", "package", - "return", "super", "this", "throw", "true", "try", "typealias", "typeof", "val", "var", "when", "while", "yield", "it", "field" + "return", "super", "this", "throw", "true", "try", "typealias", "typeof", "val", "var", "when", "while", "yield" ) -private val RESERVED_ENUM_VALUE_NAMES = arrayOf("name", "ordinal") +// Reference: +// https://kotlinlang.org/docs/enum-classes.html#working-with-enum-constants:~:text=properties%20for%20obtaining%20its%20name%20and%20position +private val KOTLIN_RESERVED_ENUM_VALUE_NAMES = arrayOf("name", "ordinal") fun String.escapeJavaReservedWord() = if (this in JAVA_RESERVED_WORDS) "${this}_" else this -fun String.escapeKotlinReservedWord() = if (this in (JAVA_RESERVED_WORDS + KOTLIN_RESERVED_WORDS)) "${this}_" else this +fun String.escapeKotlinReservedWord() = if (this in KOTLIN_RESERVED_WORDS) "${this}_" else this -fun String.escapeKotlinReservedEnumValueNames() = if (this in (JAVA_RESERVED_WORDS + KOTLIN_RESERVED_WORDS + RESERVED_ENUM_VALUE_NAMES)) "${this}_" else this +fun String.escapeKotlinReservedEnumValueNames() = if (this in (KOTLIN_RESERVED_WORDS + KOTLIN_RESERVED_ENUM_VALUE_NAMES)) "${this}_" else this diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodeGen.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodeGen.kt index 121bfbbaf51..b18982afc81 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodeGen.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodeGen.kt @@ -2,7 +2,6 @@ package com.apollographql.apollo3.compiler.codegen.java import com.apollographql.apollo3.compiler.APOLLO_VERSION import com.apollographql.apollo3.compiler.PackageNameGenerator -import com.apollographql.apollo3.compiler.codegen.CodegenLayout import com.apollographql.apollo3.compiler.codegen.ResolverInfo import com.apollographql.apollo3.compiler.codegen.java.adapter.EnumResponseAdapterBuilder import com.apollographql.apollo3.compiler.codegen.java.file.CustomScalarBuilder @@ -20,12 +19,11 @@ import com.apollographql.apollo3.compiler.codegen.java.file.OperationBuilder import com.apollographql.apollo3.compiler.codegen.java.file.OperationResponseAdapterBuilder import com.apollographql.apollo3.compiler.codegen.java.file.OperationSelectionsBuilder import com.apollographql.apollo3.compiler.codegen.java.file.OperationVariablesAdapterBuilder -import com.apollographql.apollo3.compiler.codegen.java.file.UnionBuilder import com.apollographql.apollo3.compiler.codegen.java.file.SchemaBuilder +import com.apollographql.apollo3.compiler.codegen.java.file.UnionBuilder import com.apollographql.apollo3.compiler.ir.Ir import com.apollographql.apollo3.compiler.operationoutput.OperationOutput import com.apollographql.apollo3.compiler.operationoutput.findOperationId -import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.JavaFile import java.io.File @@ -61,7 +59,7 @@ class JavaCodeGen( JavaResolver(resolverInfo.entries, acc) } - val layout = CodegenLayout( + val layout = JavaCodegenLayout( useSemanticNaming = useSemanticNaming, packageNameGenerator = packageNameGenerator, schemaPackageName = schemaPackageName @@ -212,4 +210,4 @@ fun CodeBlock.isNotEmpty() = isEmpty().not() internal const val T = "${'$'}T" internal const val L = "${'$'}L" -internal const val S = "${'$'}S" \ No newline at end of file +internal const val S = "${'$'}S" diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt new file mode 100644 index 00000000000..413da047a76 --- /dev/null +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt @@ -0,0 +1,129 @@ +package com.apollographql.apollo3.compiler.codegen.java + +import com.apollographql.apollo3.compiler.PackageNameGenerator +import com.apollographql.apollo3.compiler.capitalizeFirstLetter +import com.apollographql.apollo3.compiler.escapeJavaReservedWord +import com.apollographql.apollo3.compiler.ir.IrFieldInfo +import com.apollographql.apollo3.compiler.ir.IrListType +import com.apollographql.apollo3.compiler.ir.IrNonNullType +import com.apollographql.apollo3.compiler.ir.IrOperation +import com.apollographql.apollo3.compiler.ir.IrType +import com.apollographql.apollo3.compiler.ir.TypeSet +import com.apollographql.apollo3.compiler.singularize + +/** + * The central place where the names/packages of the different classes are decided and escape rules done. + * + * Inputs should always be GraphQL identifiers and outputs are valid Kotlin identifiers. + */ +class JavaCodegenLayout( + private val packageNameGenerator: PackageNameGenerator, + schemaPackageName: String, + private val useSemanticNaming: Boolean, +) { + private val typePackageName = "$schemaPackageName.type" + private val fragmentPackageName = "$schemaPackageName.fragment" + + // ------------------------ PackageNames --------------------------------- + + fun typePackageName() = typePackageName + fun typeAdapterPackageName() = "$typePackageName.adapter".stripDots() + + fun operationPackageName(filePath: String) = packageNameGenerator.packageName(filePath) + fun operationAdapterPackageName(filePath: String) = "${operationPackageName(filePath)}.adapter".stripDots() + fun operationResponseFieldsPackageName(filePath: String) = "${operationPackageName(filePath)}.selections".stripDots() + + @Suppress("UNUSED_PARAMETER") + fun fragmentPackageName(filePath: String?) = fragmentPackageName + + fun fragmentAdapterPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.adapter".stripDots() + fun fragmentResponseFieldsPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.selections".stripDots() + + private fun String.stripDots() = this.removePrefix(".").removeSuffix(".") + + // ------------------------ Names --------------------------------- + + internal fun compiledTypeName(name: String) = capitalizedIdentifier(name) + + internal fun enumName(name: String) = regularIdentifier(name) + + // We used to write upper case enum values but the server can define different values with different cases + // See https://github.com/apollographql/apollo-android/issues/3035 + internal fun enumValueName(name: String) = regularIdentifier(name) + internal fun enumResponseAdapterName(name: String) = enumName(name) + "_ResponseAdapter" + + internal fun operationName(operation: IrOperation): String { + val str = capitalizedIdentifier(operation.name) + + if (!useSemanticNaming) { + return str + } + + return if (str.endsWith(operation.operationType.name)) { + str + } else { + "$str${operation.operationType.name}" + } + } + + fun operationResponseAdapterWrapperName(operation: IrOperation) = operationName(operation) + "_ResponseAdapter" + fun operationVariablesAdapterName(operation: IrOperation) = operationName(operation) + "_VariablesAdapter" + fun operationSelectionsName(operation: IrOperation) = operationName(operation) + "Selections" + + internal fun fragmentName(name: String) = capitalizedIdentifier(name) + "Impl" + internal fun fragmentResponseAdapterWrapperName(name: String) = fragmentName(name) + "_ResponseAdapter" + internal fun fragmentVariablesAdapterName(name: String) = fragmentName(name) + "_VariablesAdapter" + internal fun fragmentSelectionsName(name: String) = regularIdentifier(name) + "Selections" + + internal fun inputObjectName(name: String) = capitalizedIdentifier(name) + internal fun inputObjectAdapterName(name: String) = capitalizedIdentifier(name) + "_InputAdapter" + + // variables keep the same case as their declared name + internal fun variableName(name: String) = regularIdentifier(name) + internal fun propertyName(name: String) = regularIdentifier(name) + internal fun schemaName() = "__Schema" + + // ------------------------ Helpers --------------------------------- + private fun regularIdentifier(name: String) = name.escapeJavaReservedWord() + private fun capitalizedIdentifier(name: String): String { + return name.capitalizeFirstLetter().escapeJavaReservedWord() + } + + fun rootSelectionsPropertyName() = "root" + + companion object { + private fun upperCamelCaseIgnoringNonLetters(strings: Collection): String { + return strings.map { + it.capitalizeFirstLetter() + }.joinToString("") + } + + private fun IrType.isList(): Boolean { + return when (this) { + is IrListType -> true + is IrNonNullType -> ofType.isList() + else -> false + } + } + + fun modelName(info: IrFieldInfo, typeSet: TypeSet, rawTypename: String, isOther: Boolean): String { + val responseName = if (info.type.isList()) { + info.responseName.singularize() + } else { + info.responseName + } + val name = upperCamelCaseIgnoringNonLetters((typeSet - rawTypename).sorted() + responseName) + + return (if (isOther) "Other" else "") + name + } + + fun modelName(info: IrFieldInfo): String { + val responseName = if (info.type.isList()) { + info.responseName.singularize() + } else { + info.responseName + } + return upperCamelCaseIgnoringNonLetters(setOf(responseName)) + } + } +} diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaContext.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaContext.kt index ef8b7d6b8ed..1ffccb30266 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaContext.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaContext.kt @@ -1,8 +1,6 @@ package com.apollographql.apollo3.compiler.codegen.java -import com.apollographql.apollo3.compiler.codegen.CodegenLayout - class JavaContext( - val layout : CodegenLayout, - val resolver: JavaResolver -) \ No newline at end of file + val layout: JavaCodegenLayout, + val resolver: JavaResolver, +) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt index 95757d06a4d..3462f618e6e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt @@ -1,13 +1,13 @@ package com.apollographql.apollo3.compiler.codegen.java.model import com.apollographql.apollo3.compiler.applyIf -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.codegen.java.JavaClassNames import com.apollographql.apollo3.compiler.codegen.java.JavaContext import com.apollographql.apollo3.compiler.codegen.java.adapter.toClassName import com.apollographql.apollo3.compiler.codegen.java.helpers.makeDataClassFromProperties import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDeprecation import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDescription +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.decapitalizeFirstLetter import com.apollographql.apollo3.compiler.ir.IrAccessor import com.apollographql.apollo3.compiler.ir.IrFragmentAccessor @@ -100,4 +100,4 @@ class ModelBuilder( } } } -} \ No newline at end of file +} diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodeGen.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodeGen.kt index 4c578f36b26..bf37fc995a3 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodeGen.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodeGen.kt @@ -3,7 +3,6 @@ package com.apollographql.apollo3.compiler.codegen.kotlin import com.apollographql.apollo3.compiler.APOLLO_VERSION import com.apollographql.apollo3.compiler.PackageNameGenerator import com.apollographql.apollo3.compiler.TargetLanguage -import com.apollographql.apollo3.compiler.codegen.CodegenLayout import com.apollographql.apollo3.compiler.codegen.ResolverInfo import com.apollographql.apollo3.compiler.codegen.kotlin.file.CustomScalarBuilder import com.apollographql.apollo3.compiler.codegen.kotlin.file.EnumAsEnumBuilder @@ -69,7 +68,7 @@ class KotlinCodeGen( KotlinResolver(resolverInfo.entries, acc) } - val layout = CodegenLayout( + val layout = KotlinCodegenLayout( useSemanticNaming = useSemanticNaming, packageNameGenerator = packageNameGenerator, schemaPackageName = schemaPackageName diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt similarity index 98% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt rename to apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt index 02d67fcdd5f..109339ebe3e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt @@ -1,6 +1,4 @@ - - -package com.apollographql.apollo3.compiler.codegen +package com.apollographql.apollo3.compiler.codegen.kotlin import com.apollographql.apollo3.compiler.PackageNameGenerator import com.apollographql.apollo3.compiler.capitalizeFirstLetter @@ -19,10 +17,8 @@ import com.apollographql.apollo3.compiler.singularize * The central place where the names/packages of the different classes are decided and escape rules done. * * Inputs should always be GraphQL identifiers and outputs are valid Kotlin identifiers. - * */ - -class CodegenLayout( +class KotlinCodegenLayout( private val packageNameGenerator: PackageNameGenerator, schemaPackageName: String, private val useSemanticNaming: Boolean, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinContext.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinContext.kt index 01f8ca93a88..a92c68adf1f 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinContext.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinContext.kt @@ -1,10 +1,9 @@ package com.apollographql.apollo3.compiler.codegen.kotlin import com.apollographql.apollo3.compiler.TargetLanguage -import com.apollographql.apollo3.compiler.codegen.CodegenLayout class KotlinContext( - val layout: CodegenLayout, + val layout: KotlinCodegenLayout, val resolver: KotlinResolver, val targetLanguageVersion: TargetLanguage, ) { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/TestBuildersBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/TestBuildersBuilder.kt index b79d059263b..d663f0ce44e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/TestBuildersBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/TestBuildersBuilder.kt @@ -2,7 +2,6 @@ package com.apollographql.apollo3.compiler.codegen.kotlin.file import com.apollographql.apollo3.ast.GQLType import com.apollographql.apollo3.compiler.codegen.ClassNames -import com.apollographql.apollo3.compiler.codegen.CodegenLayout import com.apollographql.apollo3.compiler.codegen.Identifier import com.apollographql.apollo3.compiler.codegen.Identifier.Data import com.apollographql.apollo3.compiler.codegen.Identifier.block @@ -11,9 +10,10 @@ import com.apollographql.apollo3.compiler.codegen.Identifier.fromJson import com.apollographql.apollo3.compiler.codegen.Identifier.testResolver import com.apollographql.apollo3.compiler.codegen.kotlin.CgFile import com.apollographql.apollo3.compiler.codegen.kotlin.CgTestFileBuilder -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinMemberNames +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.codegen.kotlin.test.TBuilderBuilder import com.apollographql.apollo3.compiler.decapitalizeFirstLetter import com.apollographql.apollo3.compiler.ir.IrModel @@ -206,7 +206,7 @@ private fun resolveNameClashes(usedNames: MutableSet, modelName: String) } -internal fun IrModel.toTBuilder(layout: CodegenLayout): TBuilder { +internal fun IrModel.toTBuilder(layout: KotlinCodegenLayout): TBuilder { val nestedBuilders = modelGroups.flatMap { it.toTBuilders(layout) } return TBuilder( kotlinName = layout.testBuilder(modelName), @@ -217,7 +217,7 @@ internal fun IrModel.toTBuilder(layout: CodegenLayout): TBuilder { ) } -internal fun IrModelGroup.toTBuilders(layout: CodegenLayout): List { +internal fun IrModelGroup.toTBuilders(layout: KotlinCodegenLayout): List { return models.filter { !it.isInterface }.map { it.toTBuilder(layout) } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt index 77db3aabe97..663666de9d1 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt @@ -2,7 +2,7 @@ package com.apollographql.apollo3.compiler.codegen.kotlin.model import com.apollographql.apollo3.compiler.TargetLanguage.KOTLIN_1_5 import com.apollographql.apollo3.compiler.applyIf -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.kotlin.adapter.from import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.makeDataClassFromProperties diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt index 5ca9e8c8efe..164ad45b674 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt @@ -15,8 +15,8 @@ import com.apollographql.apollo3.ast.GQLSelection import com.apollographql.apollo3.ast.Schema import com.apollographql.apollo3.ast.transformation.mergeTrivialInlineFragments import com.apollographql.apollo3.compiler.capitalizeFirstLetter -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.lowerCamelCaseIgnoringNonLetters -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.modelName +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.lowerCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.modelName import com.apollographql.apollo3.compiler.decapitalizeFirstLetter import com.apollographql.apollo3.compiler.escapeKotlinReservedWord @@ -478,4 +478,4 @@ private fun OperationField.toProperty(): IrProperty { requiresBuffering = fieldSet?.fields?.any { it.isSynthetic } ?: false, hidden = hide ) -} \ No newline at end of file +} diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt index 47d94d678ee..47b994f37a8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt @@ -10,8 +10,8 @@ import com.apollographql.apollo3.ast.GQLNamedType import com.apollographql.apollo3.ast.GQLNonNullType import com.apollographql.apollo3.ast.GQLSelection import com.apollographql.apollo3.ast.Schema -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.modelName -import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.modelName +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters internal class ResponseBasedModelGroupBuilder( schema: Schema, @@ -535,4 +535,4 @@ private fun List.collectFragments(): Set { is GQLFragmentSpread -> return@flatMap setOf(it.name) } }.toSet() -} \ No newline at end of file +} diff --git a/apollo-compiler/src/test/graphql/com/example/__schema/kotlin/responseBased/__schema/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/__schema/kotlin/responseBased/__schema/type/Episode.kt.expected index 480ba623e5a..f9a9a28e90b 100644 --- a/apollo-compiler/src/test/graphql/com/example/__schema/kotlin/responseBased/__schema/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/__schema/kotlin/responseBased/__schema/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/TestQuery.kt.expected index 80148d17099..6a6b5c54410 100644 --- a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/TestQuery.kt.expected @@ -37,7 +37,7 @@ public class TestQuery() : Query { public override fun selections(): List = TestQuerySelections.root public data class Data( - public val enum_: Enum? + public val `enum`: Enum? ) : Query.Data public companion object { diff --git a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected index 02f9d15b0e9..17ce0c8817b 100644 --- a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected @@ -23,17 +23,17 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var enum_: Enum? = null + var enum: Enum? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> enum_ = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) + 0 -> enum = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data( - enum_ = enum_ + enum = enum ) } @@ -43,7 +43,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("enum") - Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum_) + Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum) } } } diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected index fcaabe6fb4b..99d2780a559 100644 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/deprecation/kotlin/responseBased/deprecation/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/TestQuery.kt.expected index aa8e3edd10a..5d982d68ea1 100644 --- a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/TestQuery.kt.expected @@ -37,7 +37,7 @@ public class TestQuery() : Query { public override fun selections(): List = TestQuerySelections.root public data class Data( - public val enum_: Enum? + public val `enum`: Enum? ) : Query.Data public companion object { diff --git a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected index f7ec10f6d23..82da00821a3 100644 --- a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected @@ -23,17 +23,17 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var enum_: Enum? = null + var enum: Enum? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> enum_ = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) + 0 -> enum = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data( - enum_ = enum_ + enum = enum ) } @@ -43,7 +43,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("enum") - Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum_) + Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum) } } } diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/compat/fragment_with_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/compat/fragment_with_inline_fragment/type/Episode.kt.expected index cbf835e3f08..e9b7129ad19 100644 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/compat/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/compat/fragment_with_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected index cbf835e3f08..e9b7129ad19 100644 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/operationBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected index cbf835e3f08..e9b7129ad19 100644 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/kotlin/responseBased/fragment_with_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected index c66750996ff..d82074a6d86 100644 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/kotlin/responseBased/hero_name_query_long_name/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected index 838b278a3f7..2cf7b8fe0b7 100644 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/hero_with_review/kotlin/responseBased/hero_with_review/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/compat/inline_fragments_with_friends/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/compat/inline_fragments_with_friends/type/Episode.kt.expected index 9cfe274ebf1..32600a45d48 100644 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/compat/inline_fragments_with_friends/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/compat/inline_fragments_with_friends/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected index 9cfe274ebf1..32600a45d48 100644 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/operationBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected index 9cfe274ebf1..32600a45d48 100644 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/kotlin/responseBased/inline_fragments_with_friends/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected index 668a9a49742..418e920bba1 100644 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/input_object_type/kotlin/responseBased/input_object_type/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected index 07859c165b8..65770dc5eb9 100644 --- a/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/input_object_variable_and_argument/kotlin/responseBased/input_object_variable_and_argument/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/measurements b/apollo-compiler/src/test/graphql/com/example/measurements index 0b0c19b73d8..e19c436d39f 100644 --- a/apollo-compiler/src/test/graphql/com/example/measurements +++ b/apollo-compiler/src/test/graphql/com/example/measurements @@ -1,232 +1,232 @@ Test: Total LOC: Codegen (ms): Compilation (ms): -aggregate all 146069 3.976790674s 2m 1.096098934s -aggregate responseBased 39008 1.674340407s 54.411135326s -aggregate operationBased 81192 1.595385053s 38.074204328s -aggregate compat 25869 707.065214ms 28.610759280s +aggregate all 146069 3.683314481s 1m 47.636010028s +aggregate responseBased 39008 1.443916192s 47.533241368s +aggregate operationBased 81192 1.502899031s 35.116954126s +aggregate compat 25869 736.499258ms 24.985814534s -kotlin-responseBased-fragment_with_inline_fragment 2188 80 1.905464009s -java-operationBased-nested_named_fragments 1739 26 182.105299ms -java-operationBased-fragment_with_inline_fragment 1703 18 181.009331ms -java-operationBased-union_inline_fragments 1523 11 132.384304ms -java-operationBased-inline_fragment_intersection 1499 14 155.130027ms -java-operationBased-unique_type_name 1497 11 147.757317ms -java-operationBased-root_query_fragment_with_nested_fragments 1437 15 158.874512ms -kotlin-responseBased-nested_named_fragments 1435 105 1.093903494s -java-operationBased-mutation_create_review 1351 15 221.696211ms -kotlin-compat-fragment_with_inline_fragment 1323 30 1.311239009s -java-operationBased-__schema 1314 77 1.067132439s -java-operationBased-named_fragment_delegate 1312 12 152.621557ms -java-operationBased-named_fragment_with_variables 1223 20 153.356389ms -kotlin-compat-nested_named_fragments 1203 26 1.203411949s -kotlin-responseBased-unique_type_name 1185 33 820.504491ms -java-operationBased-nested_conditional_inline 1181 11 107.792115ms -kotlin-responseBased-named_fragment_delegate 1166 36 969.055976ms -java-operationBased-input_object_type 1162 12 162.489259ms -java-operationBased-nested_field_with_multiple_fieldsets 1152 12 147.296227ms -java-operationBased-mutation_create_review_semantic_naming 1147 11 130.085369ms -java-operationBased-fragment_used_twice 1144 15 141.290556ms -java-operationBased-multiple_fragments 1129 12 136.211343ms -java-operationBased-two_heroes_with_friends 1103 8 108.866164ms -java-operationBased-inline_fragment_merge_fields 1102 11 127.760021ms -kotlin-operationBased-nested_named_fragments 1079 34 864.883903ms -kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 32 978.074579ms -kotlin-responseBased-inline_fragment_intersection 1073 23 958.059103ms -kotlin-operationBased-fragment_with_inline_fragment 1051 30 1.147077812s -kotlin-compat-inline_fragment_intersection 1040 19 1.025980822s -java-operationBased-named_fragment_inside_inline_fragment 1037 12 115.229256ms -java-operationBased-fragments_with_type_condition 1003 10 113.886602ms -kotlin-compat-unique_type_name 994 23 761.371802ms -java-operationBased-root_query_inline_fragment 982 12 153.228101ms -kotlin-operationBased-inline_fragment_intersection 976 28 1.017684126s -kotlin-operationBased-union_inline_fragments 974 34 772.141952ms -kotlin-responseBased-union_inline_fragments 971 24 742.753122ms -kotlin-responseBased-__schema 969 357 9.716175373s -kotlin-compat-root_query_fragment_with_nested_fragments 965 32 742.816783ms -kotlin-responseBased-fragment_used_twice 952 30 950.344462ms -kotlin-operationBased-unique_type_name 938 26 713.889916ms -java-operationBased-simple_fragment_with_inline_fragments 931 10 145.073290ms -kotlin-compat-union_inline_fragments 928 19 758.636255ms -java-operationBased-inline_fragments_with_friends 923 8 125.220246ms -java-operationBased-fragment_spread_with_nested_fields 916 14 125.118769ms -kotlin-responseBased-mutation_create_review 899 24 891.447528ms -kotlin-responseBased-simple_fragment_with_inline_fragments 896 23 738.202832ms -kotlin-responseBased-fragments_with_type_condition 894 27 937.648117ms -kotlin-responseBased-nested_conditional_inline 892 17 792.464624ms -java-operationBased-fragment_spread_with_include_directive 888 12 133.354028ms -kotlin-responseBased-named_fragment_with_variables 879 26 952.200363ms -kotlin-operationBased-root_query_fragment_with_nested_fragments 876 17 817.925995ms -kotlin-responseBased-multiple_fragments 875 21 754.940715ms -java-operationBased-simple_fragment 865 14 115.081183ms -kotlin-compat-named_fragment_delegate 840 23 759.194737ms -kotlin-compat-fragment_used_twice 835 21 905.073752ms -java-operationBased-simple_union 834 17 212.425871ms -kotlin-compat-named_fragment_with_variables 833 26 903.356818ms -java-operationBased-fragments_same_type_condition 814 9 117.588909ms -kotlin-compat-nested_conditional_inline 812 15 937.699567ms -java-operationBased-hero_details 810 12 108.780120ms -java-operationBased-deprecated_merged_field 803 18 151.162745ms -kotlin-operationBased-named_fragment_delegate 803 19 736.325310ms -java-operationBased-fieldset_with_multiple_super 797 12 130.325458ms -java-operationBased-not_all_combinations_are_needed 795 10 103.649405ms -java-operationBased-simple_inline_fragment 792 6 97.778892ms -java-operationBased-inline_fragment_with_include_directive 784 7 107.378396ms -java-operationBased-test_inline 761 7 116.957228ms -kotlin-responseBased-input_object_type 755 18 758.088455ms -java-operationBased-union_fragment 752 9 132.350781ms -java-operationBased-inline_fragment_inside_inline_fragment 749 9 107.707659ms -kotlin-compat-multiple_fragments 748 16 663.149357ms -kotlin-operationBased-named_fragment_with_variables 746 21 695.902774ms -kotlin-operationBased-nested_conditional_inline 746 28 835.997743ms -kotlin-responseBased-mutation_create_review_semantic_naming 741 17 824.373078ms -kotlin-responseBased-fragment_spread_with_nested_fields 723 29 865.369867ms -kotlin-responseBased-nested_field_with_multiple_fieldsets 716 18 922.201363ms -kotlin-compat-fragments_with_type_condition 709 17 814.998535ms -kotlin-operationBased-fragment_used_twice 701 24 836.186090ms -java-operationBased-named_fragment_without_implementation 681 10 119.174683ms -kotlin-operationBased-nested_field_with_multiple_fieldsets 677 14 617.738991ms -java-operationBased-fragment_with_multiple_fieldsets 675 11 122.330504ms -java-operationBased-hero_details_semantic_naming 675 10 119.306171ms -kotlin-responseBased-simple_fragment 674 29 759.862833ms -kotlin-operationBased-inline_fragment_merge_fields 667 18 690.853250ms -kotlin-responseBased-two_heroes_with_friends 661 22 590.337568ms -kotlin-operationBased-multiple_fragments 659 19 582.654530ms -java-operationBased-path_vs_flat_accessors 658 8 91.215690ms -kotlin-compat-simple_fragment_with_inline_fragments 639 20 605.311756ms -java-operationBased-reserved_kotlin_keywords 635 6 97.022447ms -java-operationBased-typename_always_first 630 5 89.734047ms -kotlin-responseBased-inline_fragments_with_friends 626 14 664.466001ms -kotlin-operationBased-root_query_inline_fragment 623 16 792.111963ms -kotlin-operationBased-fragments_with_type_condition 621 16 686.769237ms -kotlin-operationBased-named_fragment_inside_inline_fragment 618 21 739.136646ms -kotlin-compat-nested_field_with_multiple_fieldsets 616 10 618.496853ms -kotlin-compat-named_fragment_inside_inline_fragment 613 18 756.171011ms -java-operationBased-interface_on_interface 610 7 106.431653ms -kotlin-compat-simple_fragment 610 11 642.246863ms -kotlin-compat-inline_fragments_with_friends 606 15 656.770716ms -java-operationBased-introspection_query 605 6 119.236240ms -kotlin-responseBased-deprecated_merged_field 602 31 1.037763366s -kotlin-responseBased-simple_union 601 15 567.694130ms -kotlin-responseBased-root_query_inline_fragment 595 10 608.971538ms -kotlin-compat-fragment_spread_with_nested_fields 594 25 849.275567ms -kotlin-responseBased-named_fragment_inside_inline_fragment 589 24 694.137575ms -java-operationBased-root_query_fragment 584 10 99.087164ms -kotlin-compat-fragment_spread_with_include_directive 583 21 774.854095ms -kotlin-operationBased-inline_fragments_with_friends 573 17 632.748368ms -java-operationBased-input_object_variable_and_argument 569 9 94.928514ms -java-operationBased-interface_always_nested 565 7 104.007187ms -kotlin-operationBased-simple_fragment_with_inline_fragments 565 18 715.102943ms -kotlin-compat-root_query_inline_fragment 563 13 702.301950ms -kotlin-operationBased-fragment_spread_with_nested_fields 554 16 831.174789ms -kotlin-responseBased-fragments_same_type_condition 553 18 605.184378ms -java-operationBased-deprecation 544 8 144.216933ms -kotlin-compat-simple_union 542 12 478.104865ms -kotlin-compat-inline_fragment_with_include_directive 540 11 601.579774ms -kotlin-operationBased-fragment_spread_with_include_directive 539 25 801.295660ms -java-operationBased-recursive_selection 538 6 90.442149ms -java-operationBased-hero_with_review 529 6 108.298831ms -kotlin-compat-union_fragment 529 18 478.797619ms -kotlin-compat-deprecated_merged_field 528 21 898.250542ms -kotlin-responseBased-test_inline 527 14 526.688133ms -kotlin-compat-not_all_combinations_are_needed 526 19 681.018990ms -kotlin-compat-fragments_same_type_condition 524 11 609.291165ms -kotlin-operationBased-simple_fragment 522 18 556.427596ms -kotlin-compat-inline_fragment_inside_inline_fragment 521 10 632.485915ms -kotlin-responseBased-fragment_with_multiple_fieldsets 512 20 625.097167ms -kotlin-compat-fieldset_with_multiple_super 511 15 964.145582ms -kotlin-responseBased-union_fragment 508 14 492.541118ms -java-operationBased-field_with_include_directive 507 7 113.288776ms -java-operationBased-hero_name_query_long_name 504 9 99.255820ms -java-operationBased-variable_default_value 504 4 84.162966ms -java-operationBased-hero_name 503 5 89.226908ms -kotlin-operationBased-simple_union 498 12 508.575640ms -kotlin-operationBased-inline_fragment_inside_inline_fragment 489 13 562.849405ms -kotlin-operationBased-inline_fragment_with_include_directive 489 10 564.259174ms -kotlin-responseBased-inline_fragment_merge_fields 488 10 529.017983ms -kotlin-responseBased-hero_details 487 15 639.171150ms -kotlin-compat-inline_fragment_merge_fields 486 9 520.670576ms -java-operationBased-custom_scalar_type 484 9 123.544498ms -kotlin-operationBased-fieldset_with_multiple_super 483 18 980.292883ms -kotlin-responseBased-inline_fragment_inside_inline_fragment 482 12 561.111982ms -kotlin-compat-named_fragment_without_implementation 481 40 521.324526ms -kotlin-operationBased-fragments_same_type_condition 480 16 531.916743ms -java-operationBased-optional 479 6 83.908471ms -kotlin-operationBased-simple_inline_fragment 478 11 790.661391ms -kotlin-operationBased-union_fragment 478 11 446.997240ms -kotlin-operationBased-not_all_combinations_are_needed 475 14 909.337159ms -kotlin-operationBased-deprecated_merged_field 472 31 1.295094051s -java-operationBased-inline_fragment_for_non_optional_field 471 5 99.826722ms -kotlin-responseBased-fieldset_with_multiple_super 470 21 769.279327ms -kotlin-responseBased-named_fragment_without_implementation 470 16 561.793944ms -kotlin-responseBased-simple_inline_fragment 468 9 514.811932ms -kotlin-compat-test_inline 468 10 536.496899ms -java-operationBased-inline_fragment_type_coercion 466 6 87.252396ms -java-operationBased-java8annotation 464 7 95.359674ms -java-operationBased-two_heroes_unique 459 6 81.435983ms -kotlin-compat-fragment_with_multiple_fieldsets 448 10 594.569973ms -kotlin-responseBased-not_all_combinations_are_needed 447 11 467.562682ms -kotlin-operationBased-test_inline 445 14 512.442037ms -kotlin-responseBased-reserved_kotlin_keywords 444 11 470.319268ms -kotlin-compat-simple_inline_fragment 444 9 518.099916ms -kotlin-operationBased-named_fragment_without_implementation 437 70 584.674241ms -kotlin-responseBased-path_vs_flat_accessors 422 9 470.068716ms -kotlin-compat-reserved_kotlin_keywords 421 12 460.538886ms -kotlin-operationBased-reserved_kotlin_keywords 414 10 454.908069ms -java-operationBased-starships 411 5 98.336815ms -kotlin-responseBased-hero_details_semantic_naming 409 13 537.013163ms -kotlin-compat-path_vs_flat_accessors 405 8 440.689182ms -kotlin-responseBased-interface_on_interface 400 14 492.476480ms -java-operationBased-subscriptions 400 5 86.179358ms -kotlin-responseBased-typename_always_first 400 16 446.975294ms -kotlin-operationBased-fragment_with_multiple_fieldsets 398 10 538.819049ms -java-operationBased-antlr_tokens 397 15 196.570186ms -kotlin-operationBased-path_vs_flat_accessors 391 11 441.300746ms -kotlin-responseBased-root_query_fragment 388 10 411.541294ms -kotlin-responseBased-input_object_variable_and_argument 387 9 526.748796ms -kotlin-operationBased-typename_always_first 387 11 440.005434ms -kotlin-compat-typename_always_first 387 9 417.339823ms -kotlin-compat-root_query_fragment 386 11 490.773189ms -kotlin-compat-interface_on_interface 378 11 484.578889ms -kotlin-responseBased-hero_name 376 8 535.303407ms -java-operationBased-arguments_hardcoded 374 7 132.943152ms -kotlin-operationBased-interface_on_interface 371 9 591.039467ms -kotlin-responseBased-interface_always_nested 368 9 487.594925ms -kotlin-responseBased-hero_with_review 358 10 507.997535ms -java-operationBased-merged_include 354 5 78.767910ms -kotlin-compat-interface_always_nested 353 9 519.068541ms -java-operationBased-operation_id_generator 353 4 90.534960ms -kotlin-responseBased-deprecation 350 12 727.514198ms -kotlin-responseBased-hero_name_query_long_name 348 9 449.782151ms -kotlin-compat-hero_name 344 8 484.280086ms -kotlin-operationBased-root_query_fragment 342 8 392.606217ms -java-operationBased-case_sensitive_enum 341 7 138.611357ms -java-operationBased-enum_field 341 6 118.505768ms -java-operationBased-enums_as_sealed 341 6 104.790214ms -kotlin-responseBased-custom_scalar_type 339 20 906.919527ms -kotlin-operationBased-interface_always_nested 339 12 508.150757ms -java-operationBased-nonnull 335 4 90.855646ms -kotlin-responseBased-inline_fragment_for_non_optional_field 332 8 444.914668ms -kotlin-responseBased-introspection_query 332 9 525.092229ms -kotlin-responseBased-field_with_include_directive 318 13 580.916733ms -kotlin-responseBased-variable_default_value 317 12 414.898328ms -kotlin-operationBased-hero_name 316 10 474.371246ms -kotlin-responseBased-inline_fragment_type_coercion 314 7 421.645183ms -kotlin-compat-inline_fragment_for_non_optional_field 303 8 447.554883ms -kotlin-responseBased-recursive_selection 302 8 389.255026ms -kotlin-responseBased-optional 298 8 421.166386ms -kotlin-compat-inline_fragment_type_coercion 290 17 438.741262ms -kotlin-operationBased-inline_fragment_for_non_optional_field 286 11 435.120561ms -kotlin-operationBased-inline_fragment_type_coercion 276 8 401.793567ms -kotlin-responseBased-two_heroes_unique 273 7 361.782075ms -kotlin-responseBased-java8annotation 266 10 382.118956ms -kotlin-responseBased-starships 263 8 445.207061ms -kotlin-responseBased-antlr_tokens 256 71 925.518020ms -kotlin-responseBased-subscriptions 252 10 370.927529ms -kotlin-responseBased-arguments_hardcoded 245 20 778.256125ms -kotlin-responseBased-enums_as_sealed 225 16 563.542171ms -kotlin-responseBased-operation_id_generator 207 5 345.039725ms -kotlin-responseBased-merged_include 206 5 409.629103ms -kotlin-responseBased-nonnull 191 7 380.232090ms -kotlin-responseBased-case_sensitive_enum 190 11 709.289452ms -kotlin-responseBased-enum_field 189 10 533.988961ms -kotlin-responseBased-empty 0 0 250.696393ms -java-operationBased-empty 0 0 14.485us \ No newline at end of file +kotlin-responseBased-fragment_with_inline_fragment 2188 81 1.974247754s +java-operationBased-nested_named_fragments 1739 13 155.739168ms +java-operationBased-fragment_with_inline_fragment 1703 22 202.380782ms +java-operationBased-union_inline_fragments 1523 9 120.105131ms +java-operationBased-inline_fragment_intersection 1499 25 152.998193ms +java-operationBased-unique_type_name 1497 14 122.327643ms +java-operationBased-root_query_fragment_with_nested_fragments 1437 16 143.624494ms +kotlin-responseBased-nested_named_fragments 1435 62 1.020974748s +java-operationBased-mutation_create_review 1351 18 179.770484ms +kotlin-compat-fragment_with_inline_fragment 1323 54 1.092160135s +java-operationBased-__schema 1314 68 935.367380ms +java-operationBased-named_fragment_delegate 1312 11 135.682654ms +java-operationBased-named_fragment_with_variables 1223 15 151.681397ms +kotlin-compat-nested_named_fragments 1203 28 745.395899ms +kotlin-responseBased-unique_type_name 1185 32 629.033855ms +java-operationBased-nested_conditional_inline 1181 11 114.874038ms +kotlin-responseBased-named_fragment_delegate 1166 32 757.830844ms +java-operationBased-input_object_type 1162 15 191.884306ms +java-operationBased-nested_field_with_multiple_fieldsets 1152 7 107.397239ms +java-operationBased-mutation_create_review_semantic_naming 1147 14 108.375731ms +java-operationBased-fragment_used_twice 1144 18 169.782321ms +java-operationBased-multiple_fragments 1129 12 120.522313ms +java-operationBased-two_heroes_with_friends 1103 6 95.346522ms +java-operationBased-inline_fragment_merge_fields 1102 9 173.652235ms +kotlin-operationBased-nested_named_fragments 1079 23 656.296453ms +kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 26 882.136461ms +kotlin-responseBased-inline_fragment_intersection 1073 22 841.716489ms +kotlin-operationBased-fragment_with_inline_fragment 1051 26 1.025132227s +kotlin-compat-inline_fragment_intersection 1040 30 869.997249ms +java-operationBased-named_fragment_inside_inline_fragment 1037 12 115.317475ms +java-operationBased-fragments_with_type_condition 1003 15 183.653463ms +kotlin-compat-unique_type_name 994 21 568.194587ms +java-operationBased-root_query_inline_fragment 982 7 216.738005ms +kotlin-operationBased-inline_fragment_intersection 976 51 1.290619354s +kotlin-operationBased-union_inline_fragments 974 21 754.377351ms +kotlin-responseBased-union_inline_fragments 971 21 561.918582ms +kotlin-responseBased-__schema 969 225 6.053858327s +kotlin-compat-root_query_fragment_with_nested_fragments 965 19 643.147175ms +kotlin-responseBased-fragment_used_twice 952 29 965.967650ms +kotlin-operationBased-unique_type_name 938 15 613.579705ms +java-operationBased-simple_fragment_with_inline_fragments 931 7 94.111900ms +kotlin-compat-union_inline_fragments 928 14 597.082512ms +java-operationBased-inline_fragments_with_friends 923 17 159.433486ms +java-operationBased-fragment_spread_with_nested_fields 916 19 161.162094ms +kotlin-responseBased-mutation_create_review 899 24 862.794508ms +kotlin-responseBased-simple_fragment_with_inline_fragments 896 19 552.113303ms +kotlin-responseBased-fragments_with_type_condition 894 24 690.834391ms +kotlin-responseBased-nested_conditional_inline 892 16 841.727087ms +java-operationBased-fragment_spread_with_include_directive 888 18 179.990791ms +kotlin-responseBased-named_fragment_with_variables 879 21 703.070802ms +kotlin-operationBased-root_query_fragment_with_nested_fragments 876 16 626.827824ms +kotlin-responseBased-multiple_fragments 875 29 596.084050ms +java-operationBased-simple_fragment 865 12 113.243634ms +kotlin-compat-named_fragment_delegate 840 18 693.291361ms +kotlin-compat-fragment_used_twice 835 30 1.321887815s +java-operationBased-simple_union 834 12 101.412032ms +kotlin-compat-named_fragment_with_variables 833 23 664.802903ms +java-operationBased-fragments_same_type_condition 814 13 172.415415ms +kotlin-compat-nested_conditional_inline 812 17 674.746981ms +java-operationBased-hero_details 810 8 119.367084ms +java-operationBased-deprecated_merged_field 803 24 173.418647ms +kotlin-operationBased-named_fragment_delegate 803 42 554.291375ms +java-operationBased-fieldset_with_multiple_super 797 17 176.656345ms +java-operationBased-not_all_combinations_are_needed 795 7 104.421458ms +java-operationBased-simple_inline_fragment 792 5 92.489479ms +java-operationBased-inline_fragment_with_include_directive 784 9 108.628089ms +java-operationBased-test_inline 761 4 83.141330ms +kotlin-responseBased-input_object_type 755 20 855.655933ms +java-operationBased-union_fragment 752 6 104.575665ms +java-operationBased-inline_fragment_inside_inline_fragment 749 15 167.864284ms +kotlin-compat-multiple_fragments 748 18 601.331645ms +kotlin-operationBased-named_fragment_with_variables 746 17 558.808046ms +kotlin-operationBased-nested_conditional_inline 746 28 609.362695ms +kotlin-responseBased-mutation_create_review_semantic_naming 741 33 850.299600ms +kotlin-responseBased-fragment_spread_with_nested_fields 723 30 910.117815ms +kotlin-responseBased-nested_field_with_multiple_fieldsets 716 11 713.020306ms +kotlin-compat-fragments_with_type_condition 709 17 630.891015ms +kotlin-operationBased-fragment_used_twice 701 26 807.999349ms +java-operationBased-named_fragment_without_implementation 681 7 132.970128ms +kotlin-operationBased-nested_field_with_multiple_fieldsets 677 13 534.709937ms +java-operationBased-fragment_with_multiple_fieldsets 675 19 147.149313ms +java-operationBased-hero_details_semantic_naming 675 9 108.483777ms +kotlin-responseBased-simple_fragment 674 14 524.018157ms +kotlin-operationBased-inline_fragment_merge_fields 667 16 574.163005ms +kotlin-responseBased-two_heroes_with_friends 661 13 537.514156ms +kotlin-operationBased-multiple_fragments 659 17 568.018408ms +java-operationBased-path_vs_flat_accessors 658 5 86.707438ms +kotlin-compat-simple_fragment_with_inline_fragments 639 11 524.190694ms +java-operationBased-reserved_kotlin_keywords 635 7 139.460804ms +java-operationBased-typename_always_first 630 4 79.507036ms +kotlin-responseBased-inline_fragments_with_friends 626 14 719.684981ms +kotlin-operationBased-root_query_inline_fragment 623 12 604.679603ms +kotlin-operationBased-fragments_with_type_condition 621 21 726.107561ms +kotlin-operationBased-named_fragment_inside_inline_fragment 618 20 787.838555ms +kotlin-compat-nested_field_with_multiple_fieldsets 616 11 472.610719ms +kotlin-compat-named_fragment_inside_inline_fragment 613 33 904.925649ms +java-operationBased-interface_on_interface 610 7 98.826297ms +kotlin-compat-simple_fragment 610 11 439.060592ms +kotlin-compat-inline_fragments_with_friends 606 63 619.303947ms +java-operationBased-introspection_query 605 5 89.893583ms +kotlin-responseBased-deprecated_merged_field 602 26 947.659980ms +kotlin-responseBased-simple_union 601 12 459.683513ms +kotlin-responseBased-root_query_inline_fragment 595 14 1.036581624s +kotlin-compat-fragment_spread_with_nested_fields 594 14 724.027529ms +kotlin-responseBased-named_fragment_inside_inline_fragment 589 24 547.141504ms +java-operationBased-root_query_fragment 584 13 119.430720ms +kotlin-compat-fragment_spread_with_include_directive 583 24 894.805542ms +kotlin-operationBased-inline_fragments_with_friends 573 12 570.802068ms +java-operationBased-input_object_variable_and_argument 569 8 105.603278ms +java-operationBased-interface_always_nested 565 6 96.530145ms +kotlin-operationBased-simple_fragment_with_inline_fragments 565 13 564.219419ms +kotlin-compat-root_query_inline_fragment 563 16 548.041672ms +kotlin-operationBased-fragment_spread_with_nested_fields 554 19 705.879160ms +kotlin-responseBased-fragments_same_type_condition 553 22 748.092577ms +java-operationBased-deprecation 544 10 123.613584ms +kotlin-compat-simple_union 542 13 379.636056ms +kotlin-compat-inline_fragment_with_include_directive 540 9 539.390091ms +kotlin-operationBased-fragment_spread_with_include_directive 539 17 923.920229ms +java-operationBased-recursive_selection 538 7 102.736220ms +java-operationBased-hero_with_review 529 6 90.410073ms +kotlin-compat-union_fragment 529 8 421.097392ms +kotlin-compat-deprecated_merged_field 528 26 879.361643ms +kotlin-responseBased-test_inline 527 15 405.728591ms +kotlin-compat-not_all_combinations_are_needed 526 12 458.149270ms +kotlin-compat-fragments_same_type_condition 524 13 544.994323ms +kotlin-operationBased-simple_fragment 522 19 601.814664ms +kotlin-compat-inline_fragment_inside_inline_fragment 521 20 610.003503ms +kotlin-responseBased-fragment_with_multiple_fieldsets 512 16 647.853969ms +kotlin-compat-fieldset_with_multiple_super 511 14 745.453429ms +kotlin-responseBased-union_fragment 508 11 395.252527ms +java-operationBased-field_with_include_directive 507 6 108.142266ms +java-operationBased-hero_name_query_long_name 504 9 106.640110ms +java-operationBased-variable_default_value 504 4 79.160546ms +java-operationBased-hero_name 503 13 106.690824ms +kotlin-operationBased-simple_union 498 9 361.132368ms +kotlin-operationBased-inline_fragment_inside_inline_fragment 489 13 670.731368ms +kotlin-operationBased-inline_fragment_with_include_directive 489 10 498.827963ms +kotlin-responseBased-inline_fragment_merge_fields 488 17 480.214835ms +kotlin-responseBased-hero_details 487 12 537.438449ms +kotlin-compat-inline_fragment_merge_fields 486 14 611.792960ms +java-operationBased-custom_scalar_type 484 10 154.874890ms +kotlin-operationBased-fieldset_with_multiple_super 483 17 828.253049ms +kotlin-responseBased-inline_fragment_inside_inline_fragment 482 10 539.026671ms +kotlin-compat-named_fragment_without_implementation 481 9 467.421639ms +kotlin-operationBased-fragments_same_type_condition 480 12 508.503265ms +java-operationBased-optional 479 4 92.174863ms +kotlin-operationBased-simple_inline_fragment 478 13 405.528058ms +kotlin-operationBased-union_fragment 478 9 431.918369ms +kotlin-operationBased-not_all_combinations_are_needed 475 10 598.350989ms +kotlin-operationBased-deprecated_merged_field 472 24 891.456141ms +java-operationBased-inline_fragment_for_non_optional_field 471 5 147.403389ms +kotlin-responseBased-fieldset_with_multiple_super 470 17 837.155318ms +kotlin-responseBased-named_fragment_without_implementation 470 15 394.577763ms +kotlin-responseBased-simple_inline_fragment 468 8 401.910741ms +kotlin-compat-test_inline 468 11 457.372883ms +java-operationBased-inline_fragment_type_coercion 466 4 130.089045ms +java-operationBased-java8annotation 464 9 90.834770ms +java-operationBased-two_heroes_unique 459 3 77.032603ms +kotlin-compat-fragment_with_multiple_fieldsets 448 13 450.971854ms +kotlin-responseBased-not_all_combinations_are_needed 447 9 440.914071ms +kotlin-operationBased-test_inline 445 9 427.723620ms +kotlin-responseBased-reserved_kotlin_keywords 444 11 568.357034ms +kotlin-compat-simple_inline_fragment 444 9 466.057618ms +kotlin-operationBased-named_fragment_without_implementation 437 9 477.845161ms +kotlin-responseBased-path_vs_flat_accessors 422 8 386.171430ms +kotlin-compat-reserved_kotlin_keywords 421 9 395.092922ms +kotlin-operationBased-reserved_kotlin_keywords 414 10 390.753681ms +java-operationBased-starships 411 3 73.402ms +kotlin-responseBased-hero_details_semantic_naming 409 19 457.246418ms +kotlin-compat-path_vs_flat_accessors 405 6 476.185657ms +kotlin-responseBased-interface_on_interface 400 7 471.685435ms +java-operationBased-subscriptions 400 5 79.025275ms +kotlin-responseBased-typename_always_first 400 46 355.490895ms +kotlin-operationBased-fragment_with_multiple_fieldsets 398 12 695.642117ms +java-operationBased-antlr_tokens 397 21 175.437700ms +kotlin-operationBased-path_vs_flat_accessors 391 8 372.453930ms +kotlin-responseBased-root_query_fragment 388 8 417.917967ms +kotlin-responseBased-input_object_variable_and_argument 387 12 586.170204ms +kotlin-operationBased-typename_always_first 387 6 324.349975ms +kotlin-compat-typename_always_first 387 14 403.396957ms +kotlin-compat-root_query_fragment 386 7 359.874393ms +kotlin-compat-interface_on_interface 378 8 353.275181ms +kotlin-responseBased-hero_name 376 7 437.809322ms +java-operationBased-arguments_hardcoded 374 7 138.967468ms +kotlin-operationBased-interface_on_interface 371 8 509.813894ms +kotlin-responseBased-interface_always_nested 368 8 431.286936ms +kotlin-responseBased-hero_with_review 358 10 455.590512ms +java-operationBased-merged_include 354 3 83.027588ms +kotlin-compat-interface_always_nested 353 8 409.396006ms +java-operationBased-operation_id_generator 353 7 106.275301ms +kotlin-responseBased-deprecation 350 18 691.849302ms +kotlin-responseBased-hero_name_query_long_name 348 9 536.133133ms +kotlin-compat-hero_name 344 6 418.189917ms +kotlin-operationBased-root_query_fragment 342 10 398.495256ms +java-operationBased-case_sensitive_enum 341 5 122.569572ms +java-operationBased-enum_field 341 7 137.031503ms +java-operationBased-enums_as_sealed 341 10 94.663923ms +kotlin-responseBased-custom_scalar_type 339 16 891.796752ms +kotlin-operationBased-interface_always_nested 339 7 543.604506ms +java-operationBased-nonnull 335 3 71.681798ms +kotlin-responseBased-inline_fragment_for_non_optional_field 332 8 522.784160ms +kotlin-responseBased-introspection_query 332 7 353.795127ms +kotlin-responseBased-field_with_include_directive 318 12 534.045236ms +kotlin-responseBased-variable_default_value 317 8 454.820909ms +kotlin-operationBased-hero_name 316 8 465.687250ms +kotlin-responseBased-inline_fragment_type_coercion 314 8 401.729327ms +kotlin-compat-inline_fragment_for_non_optional_field 303 8 562.134132ms +kotlin-responseBased-recursive_selection 302 6 422.446653ms +kotlin-responseBased-optional 298 11 548.775470ms +kotlin-compat-inline_fragment_type_coercion 290 5 346.671087ms +kotlin-operationBased-inline_fragment_for_non_optional_field 286 6 531.645300ms +kotlin-operationBased-inline_fragment_type_coercion 276 9 418.781459ms +kotlin-responseBased-two_heroes_unique 273 5 287.765393ms +kotlin-responseBased-java8annotation 266 6 434.844080ms +kotlin-responseBased-starships 263 5 321.700933ms +kotlin-responseBased-antlr_tokens 256 47 831.538072ms +kotlin-responseBased-subscriptions 252 5 283.110486ms +kotlin-responseBased-arguments_hardcoded 245 22 785.651083ms +kotlin-responseBased-enums_as_sealed 225 13 514.517686ms +kotlin-responseBased-operation_id_generator 207 6 389.207761ms +kotlin-responseBased-merged_include 206 5 281.955124ms +kotlin-responseBased-nonnull 191 7 273.083341ms +kotlin-responseBased-case_sensitive_enum 190 10 634.559034ms +kotlin-responseBased-enum_field 189 10 495.058499ms +kotlin-responseBased-empty 0 0 210.495722ms +java-operationBased-empty 0 0 8.882us \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected index 3ad3a09656e..dde832d84c1 100644 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/kotlin/responseBased/mutation_create_review/type/Episode.kt.expected @@ -36,7 +36,7 @@ internal enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected index 36087537948..148ef73c5b7 100644 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/kotlin/responseBased/mutation_create_review_semantic_naming/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/compat/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/compat/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 34f5e74eca1..378ad30595e 100644 --- a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/compat/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/compat/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 34f5e74eca1..378ad30595e 100644 --- a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/operationBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected index 34f5e74eca1..378ad30595e 100644 --- a/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/named_fragment_inside_inline_fragment/kotlin/responseBased/named_fragment_inside_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/compat/nested_conditional_inline/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/compat/nested_conditional_inline/type/Episode.kt.expected index 4d79a0cd5bf..a6321fea2f1 100644 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/compat/nested_conditional_inline/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/compat/nested_conditional_inline/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected index 4d79a0cd5bf..a6321fea2f1 100644 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/operationBased/nested_conditional_inline/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected index 4d79a0cd5bf..a6321fea2f1 100644 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/kotlin/responseBased/nested_conditional_inline/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected index 3a5f7e4a309..41c0818704c 100644 --- a/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/optional/kotlin/responseBased/optional/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected index 45e005bc367..0b84f1b9cec 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected @@ -113,7 +113,7 @@ public class TestQuery implements Query { } public static class Data implements Query.Data { - public Yield yield_; + public Yield yield; public List objects; @@ -123,8 +123,8 @@ public class TestQuery implements Query { private transient volatile String $toString; - public Data(Yield yield_, List objects) { - this.yield_ = yield_; + public Data(Yield yield, List objects) { + this.yield = yield; this.objects = objects; } @@ -135,7 +135,7 @@ public class TestQuery implements Query { } if (o instanceof Data) { Data that = (Data) o; - return ((this.yield_ == null) ? (that.yield_ == null) : this.yield_.equals(that.yield_)) + return ((this.yield == null) ? (that.yield == null) : this.yield.equals(that.yield)) &&((this.objects == null) ? (that.objects == null) : this.objects.equals(that.objects)); } return false; @@ -146,7 +146,7 @@ public class TestQuery implements Query { if (!$hashCodeMemoized) { int h = 1; h *= 1000003; - h ^= (yield_ == null) ? 0 : yield_.hashCode(); + h ^= (yield == null) ? 0 : yield.hashCode(); h *= 1000003; h ^= (objects == null) ? 0 : objects.hashCode(); $hashCode = h; @@ -159,7 +159,7 @@ public class TestQuery implements Query { public String toString() { if ($toString == null) { $toString = "Data{" - + "yield_=" + yield_ + ", " + + "yield=" + yield + ", " + "objects=" + objects + "}"; } @@ -171,7 +171,7 @@ public class TestQuery implements Query { /** * The ID of the character */ - public String it_; + public String it; /** * The name of the character @@ -184,8 +184,8 @@ public class TestQuery implements Query { private transient volatile String $toString; - public Yield(String it_, String name) { - this.it_ = it_; + public Yield(String it, String name) { + this.it = it; this.name = name; } @@ -196,7 +196,7 @@ public class TestQuery implements Query { } if (o instanceof Yield) { Yield that = (Yield) o; - return ((this.it_ == null) ? (that.it_ == null) : this.it_.equals(that.it_)) + return ((this.it == null) ? (that.it == null) : this.it.equals(that.it)) &&((this.name == null) ? (that.name == null) : this.name.equals(that.name)); } return false; @@ -207,7 +207,7 @@ public class TestQuery implements Query { if (!$hashCodeMemoized) { int h = 1; h *= 1000003; - h ^= (it_ == null) ? 0 : it_.hashCode(); + h ^= (it == null) ? 0 : it.hashCode(); h *= 1000003; h ^= (name == null) ? 0 : name.hashCode(); $hashCode = h; @@ -220,7 +220,7 @@ public class TestQuery implements Query { public String toString() { if ($toString == null) { $toString = "Yield{" - + "it_=" + it_ + ", " + + "it=" + it + ", " + "name=" + name + "}"; } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected index 0ed28c0e8da..80054cb0709 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected @@ -35,20 +35,20 @@ public class TestQuery_ResponseAdapter { @Override public TestQuery.Data fromJson(JsonReader reader, CustomScalarAdapters customScalarAdapters) throws IOException { - TestQuery.Yield yield_ = null; + TestQuery.Yield yield = null; List objects = null; loop: while(true) { switch (reader.selectName(RESPONSE_NAMES)) { - case 0: yield_ = new NullableAdapter<>(new ObjectAdapter(Yield.INSTANCE, false)).fromJson(reader, customScalarAdapters); break; + case 0: yield = new NullableAdapter<>(new ObjectAdapter(Yield.INSTANCE, false)).fromJson(reader, customScalarAdapters); break; case 1: objects = new NullableAdapter<>(new ListAdapter<>(new NullableAdapter<>(new ObjectAdapter(Object.INSTANCE, true)))).fromJson(reader, customScalarAdapters); break; default: break loop; } } return new TestQuery.Data( - yield_, + yield, objects ); } @@ -57,7 +57,7 @@ public class TestQuery_ResponseAdapter { public void toJson(JsonWriter writer, CustomScalarAdapters customScalarAdapters, TestQuery.Data value) throws IOException { writer.name("yield"); - new NullableAdapter<>(new ObjectAdapter(Yield.INSTANCE, false)).toJson(writer, customScalarAdapters, value.yield_); + new NullableAdapter<>(new ObjectAdapter(Yield.INSTANCE, false)).toJson(writer, customScalarAdapters, value.yield); writer.name("objects"); new NullableAdapter<>(new ListAdapter<>(new NullableAdapter<>(new ObjectAdapter(Object.INSTANCE, true)))).toJson(writer, customScalarAdapters, value.objects); @@ -72,23 +72,23 @@ public class TestQuery_ResponseAdapter { @Override public TestQuery.Yield fromJson(JsonReader reader, CustomScalarAdapters customScalarAdapters) throws IOException { - String it_ = null; + String it = null; String name = null; loop: while(true) { switch (reader.selectName(RESPONSE_NAMES)) { - case 0: it_ = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; + case 0: it = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; case 1: name = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; default: break loop; } } - Assertions.checkFieldNotMissing(it_, "it"); + Assertions.checkFieldNotMissing(it, "it"); Assertions.checkFieldNotMissing(name, "name"); return new TestQuery.Yield( - it_, + it, name ); } @@ -97,7 +97,7 @@ public class TestQuery_ResponseAdapter { public void toJson(JsonWriter writer, CustomScalarAdapters customScalarAdapters, TestQuery.Yield value) throws IOException { writer.name("it"); - Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.it_); + Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.it); writer.name("name"); Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.name); diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected index d12c0796ab1..b8a7ec7e15d 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected @@ -18,7 +18,7 @@ import java.util.Arrays; import java.util.List; public class TestQuerySelections { - private static List yield_ = Arrays.asList( + private static List yield = Arrays.asList( new CompiledField.Builder("id", new CompiledNotNullType(CompiledGraphQL.CompiledIDType)).alias("it").build(), new CompiledField.Builder("name", new CompiledNotNullType(CompiledGraphQL.CompiledStringType)).build() ); @@ -33,7 +33,7 @@ public class TestQuerySelections { ); public static List root = Arrays.asList( - new CompiledField.Builder("hero", Character.type).alias("yield").selections(yield_).build(), + new CompiledField.Builder("hero", Character.type).alias("yield").selections(yield).build(), new CompiledField.Builder("search", new CompiledListType(SearchResult.type)).alias("objects").arguments(Arrays.asList(new CompiledArgument("text", "abc", false))).selections(objects).build() ); } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected index bc30b9e329d..29164d1ae3f 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected @@ -46,7 +46,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it_: String, + public val it: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index f7486f00dc8..1e625c497ac 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -63,19 +63,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Yield { - var it_: String? = null + var it: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Yield( - it_ = it_!!, + it = it!!, name = name!! ) } @@ -86,7 +86,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Yield ): Unit { writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it_) + StringAdapter.toJson(writer, customScalarAdapters, value.it) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected index 219faf1f277..91cc1041c2b 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it_: String, + public val it: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index bdb45037ee0..c606476f9cd 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -62,19 +62,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var it_: String? = null + var it: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - it_ = it_!!, + it = it!!, name = name!! ) } @@ -85,7 +85,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data.Yield ): Unit { writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it_) + StringAdapter.toJson(writer, customScalarAdapters, value.it) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected index 138addef19d..2a30401d85b 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it_: String, + public val it: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index 0d1a446e594..b7dc3881094 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -59,19 +59,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var it_: String? = null + var it: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - it_ = it_!!, + it = it!!, name = name!! ) } @@ -82,7 +82,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data.Yield ): Unit { writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it_) + StringAdapter.toJson(writer, customScalarAdapters, value.it) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/compat/root_query_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/compat/root_query_inline_fragment/type/Episode.kt.expected index 07ba2ea11dc..b16d5ace129 100644 --- a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/compat/root_query_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/compat/root_query_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected index 07ba2ea11dc..b16d5ace129 100644 --- a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/operationBased/root_query_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected index 07ba2ea11dc..b16d5ace129 100644 --- a/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/root_query_inline_fragment/kotlin/responseBased/root_query_inline_fragment/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/compat/union_inline_fragments/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/compat/union_inline_fragments/type/Episode.kt.expected index 28ee36bb451..c78b111c8d8 100644 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/compat/union_inline_fragments/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/compat/union_inline_fragments/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected index 28ee36bb451..c78b111c8d8 100644 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/operationBased/union_inline_fragments/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected index 28ee36bb451..c78b111c8d8 100644 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/kotlin/responseBased/union_inline_fragments/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/compat/unique_type_name/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/compat/unique_type_name/type/Episode.kt.expected index dda3adf2e66..aae4762a209 100644 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/compat/unique_type_name/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/compat/unique_type_name/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected index dda3adf2e66..aae4762a209 100644 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/operationBased/unique_type_name/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected index dda3adf2e66..aae4762a209 100644 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/unique_type_name/kotlin/responseBased/unique_type_name/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected b/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected index 3fd245851b1..19ffe9e7327 100644 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/variable_default_value/kotlin/responseBased/variable_default_value/type/Episode.kt.expected @@ -36,7 +36,7 @@ public enum class Episode( * Test java reserved word */ @Deprecated(message = "For test purpose only") - new_("new"), + new("new"), /** * Auto generated constant for unknown enum values */ diff --git a/tests/custom-scalars/src/test/kotlin/test/CustomScalarTest.kt b/tests/custom-scalars/src/test/kotlin/test/CustomScalarTest.kt index b3252d41c0f..1c8f0805bcd 100644 --- a/tests/custom-scalars/src/test/kotlin/test/CustomScalarTest.kt +++ b/tests/custom-scalars/src/test/kotlin/test/CustomScalarTest.kt @@ -35,8 +35,8 @@ class CustomScalarTest { .execute() .dataAssertNoErrors - assertEquals(10_000_000_000, data.long_) - assertEquals(1.4f, data.float_) + assertEquals(10_000_000_000, data.long) + assertEquals(1.4f, data.float) assertEquals(mapOf("key" to "value"), data.any) assertEquals(listOf( mapOf("lat" to 1, "lon" to 2), @@ -88,4 +88,4 @@ class CustomScalarTest { assertEquals(Address("Downing Street", 10), data.address) } -} \ No newline at end of file +} From 6bdd7c12baf02adf9fc0b0638cb4e0087919e6ae Mon Sep 17 00:00:00 2001 From: BoD Date: Tue, 30 Nov 2021 18:29:30 +0100 Subject: [PATCH 2/7] Make CodegenLayout a common class with 2 small subclasses --- .../apollo3/compiler/codegen/CodegenLayout.kt | 147 ++++++++++++++++++ .../codegen/java/JavaCodegenLayout.kt | 126 +-------------- .../codegen/java/model/ModelBuilder.kt | 2 +- .../codegen/kotlin/KotlinCodegenLayout.kt | 139 +---------------- .../codegen/kotlin/model/ModelBuilder.kt | 2 +- .../ir/OperationBasedModelGroupBuilder.kt | 4 +- .../ir/ResponseBasedModelGroupBuilder.kt | 4 +- .../TestOperation.graphql | 2 +- .../TestQuery.java.expected | 24 +-- .../TestQuery_ResponseAdapter.java.expected | 22 +-- .../TestQuerySelections.java.expected | 8 +- .../type/Character.java.expected | 2 +- .../type/Droid.java.expected | 2 +- .../type/Human.java.expected | 2 +- .../type/SearchResult.java.expected | 2 +- .../type/Starship.java.expected | 2 +- .../reserved_keywords}/TestQuery.kt.expected | 14 +- .../TestQuery_ResponseAdapter.kt.expected | 20 +-- .../TestQuerySelections.kt.expected | 8 +- .../type/Character.kt.expected | 2 +- .../reserved_keywords}/type/Droid.kt.expected | 2 +- .../reserved_keywords}/type/Human.kt.expected | 2 +- .../type/SearchResult.kt.expected | 2 +- .../type/Starship.kt.expected | 2 +- .../reserved_keywords}/TestQuery.kt.expected | 14 +- .../TestQuery_ResponseAdapter.kt.expected | 20 +-- .../TestQuerySelections.kt.expected | 8 +- .../type/Character.kt.expected | 2 +- .../reserved_keywords}/type/Droid.kt.expected | 2 +- .../reserved_keywords}/type/Human.kt.expected | 2 +- .../type/SearchResult.kt.expected | 2 +- .../type/Starship.kt.expected | 2 +- .../reserved_keywords}/TestQuery.kt.expected | 14 +- .../TestQuery_ResponseAdapter.kt.expected | 16 +- .../TestQuerySelections.kt.expected | 8 +- .../type/Character.kt.expected | 2 +- .../reserved_keywords}/type/Droid.kt.expected | 2 +- .../reserved_keywords}/type/Human.kt.expected | 2 +- .../type/SearchResult.kt.expected | 2 +- .../type/Starship.kt.expected | 2 +- 40 files changed, 272 insertions(+), 370 deletions(-) create mode 100644 apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords => reserved_keywords}/TestOperation.graphql (90%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/TestQuery.java.expected (91%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/adapter/TestQuery_ResponseAdapter.java.expected (89%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/selections/TestQuerySelections.java.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/type/Character.java.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/type/Droid.java.expected (89%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/type/Human.java.expected (89%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/type/SearchResult.java.expected (85%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords => reserved_keywords/java/operationBased/reserved_keywords}/type/Starship.java.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/TestQuery.kt.expected (83%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/adapter/TestQuery_ResponseAdapter.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/selections/TestQuerySelections.kt.expected (90%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/type/Character.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/type/Droid.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/type/Human.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/type/SearchResult.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/compat/reserved_keywords}/type/Starship.kt.expected (85%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/TestQuery.kt.expected (83%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/adapter/TestQuery_ResponseAdapter.kt.expected (89%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/selections/TestQuerySelections.kt.expected (90%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/type/Character.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/type/Droid.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/type/Human.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/type/SearchResult.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/operationBased/reserved_keywords}/type/Starship.kt.expected (85%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/TestQuery.kt.expected (84%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/adapter/TestQuery_ResponseAdapter.kt.expected (94%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/selections/TestQuerySelections.kt.expected (90%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/type/Character.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/type/Droid.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/type/Human.kt.expected (88%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/type/SearchResult.kt.expected (87%) rename apollo-compiler/src/test/graphql/com/example/{reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords => reserved_keywords/kotlin/responseBased/reserved_keywords}/type/Starship.kt.expected (85%) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt new file mode 100644 index 00000000000..a2cc40b9e00 --- /dev/null +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt @@ -0,0 +1,147 @@ +package com.apollographql.apollo3.compiler.codegen + +import com.apollographql.apollo3.compiler.PackageNameGenerator +import com.apollographql.apollo3.compiler.capitalizeFirstLetter +import com.apollographql.apollo3.compiler.decapitalizeFirstLetter +import com.apollographql.apollo3.compiler.ir.IrFieldInfo +import com.apollographql.apollo3.compiler.ir.IrListType +import com.apollographql.apollo3.compiler.ir.IrNonNullType +import com.apollographql.apollo3.compiler.ir.IrOperation +import com.apollographql.apollo3.compiler.ir.IrType +import com.apollographql.apollo3.compiler.ir.TypeSet +import com.apollographql.apollo3.compiler.singularize + +/** + * The central place where the names/packages of the different classes are decided and escape rules done. + * + * Inputs should always be GraphQL identifiers and outputs are valid Kotlin/Java identifiers. + */ +abstract class CodegenLayout( + private val packageNameGenerator: PackageNameGenerator, + schemaPackageName: String, + private val useSemanticNaming: Boolean, +) { + private val typePackageName = "$schemaPackageName.type" + private val fragmentPackageName = "$schemaPackageName.fragment" + + // ------------------------ FileNames --------------------------------- + + internal fun fragmentModelsFileName(name: String) = capitalizedIdentifier(name) + + // ------------------------ PackageNames --------------------------------- + + fun typePackageName() = typePackageName + fun typeAdapterPackageName() = "$typePackageName.adapter".stripDots() + + fun operationPackageName(filePath: String) = packageNameGenerator.packageName(filePath) + fun operationAdapterPackageName(filePath: String) = "${operationPackageName(filePath)}.adapter".stripDots() + fun operationTestBuildersPackageName(filePath: String) = "${operationPackageName(filePath)}.test".stripDots() + fun operationResponseFieldsPackageName(filePath: String) = "${operationPackageName(filePath)}.selections".stripDots() + + @Suppress("UNUSED_PARAMETER") + fun fragmentPackageName(filePath: String?) = fragmentPackageName + + fun fragmentAdapterPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.adapter".stripDots() + fun fragmentResponseFieldsPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.selections".stripDots() + + private fun String.stripDots() = this.removePrefix(".").removeSuffix(".") + + // ------------------------ Names --------------------------------- + + internal fun compiledTypeName(name: String) = capitalizedIdentifier(name) + + internal fun enumName(name: String) = regularIdentifier(name) + + // We used to write upper case enum values but the server can define different values with different cases + // See https://github.com/apollographql/apollo-android/issues/3035 + internal fun enumValueName(name: String) = regularIdentifier(name) + internal fun enumResponseAdapterName(name: String) = enumName(name) + "_ResponseAdapter" + + internal fun operationName(operation: IrOperation): String { + val str = capitalizedIdentifier(operation.name) + + if (!useSemanticNaming) { + return str + } + + return if (str.endsWith(operation.operationType.name)) { + str + } else { + "$str${operation.operationType.name}" + } + } + + fun operationResponseAdapterWrapperName(operation: IrOperation) = operationName(operation) + "_ResponseAdapter" + fun operationTestBuildersWrapperName(operation: IrOperation) = operationName(operation) + "_TestBuilder" + fun operationVariablesAdapterName(operation: IrOperation) = operationName(operation) + "_VariablesAdapter" + fun operationSelectionsName(operation: IrOperation) = operationName(operation) + "Selections" + + internal fun fragmentName(name: String) = capitalizedIdentifier(name) + "Impl" + internal fun fragmentResponseAdapterWrapperName(name: String) = fragmentName(name) + "_ResponseAdapter" + internal fun fragmentVariablesAdapterName(name: String) = fragmentName(name) + "_VariablesAdapter" + internal fun fragmentSelectionsName(name: String) = regularIdentifier(name) + "Selections" + + internal fun inputObjectName(name: String) = capitalizedIdentifier(name) + internal fun inputObjectAdapterName(name: String) = capitalizedIdentifier(name) + "_InputAdapter" + + // variables keep the same case as their declared name + internal fun variableName(name: String) = regularIdentifier(name) + internal fun propertyName(name: String) = regularIdentifier(name) + internal fun schemaName() = "__Schema" + + // ------------------------ Helpers --------------------------------- + + abstract fun escapeReservedWord(word: String): String + + private fun regularIdentifier(name: String) = escapeReservedWord(name) + private fun capitalizedIdentifier(name: String): String { + return escapeReservedWord(name.capitalizeFirstLetter()) + } + + fun rootSelectionsPropertyName() = "root" + fun testBuilder(modelName: String): String { + return "${modelName}Builder" + } + + companion object { + fun upperCamelCaseIgnoringNonLetters(strings: Collection): String { + return strings.map { + it.capitalizeFirstLetter() + }.joinToString("") + } + + fun lowerCamelCaseIgnoringNonLetters(strings: Collection): String { + return strings.map { + it.decapitalizeFirstLetter() + }.joinToString("") + } + + private fun IrType.isList(): Boolean { + return when (this) { + is IrListType -> true + is IrNonNullType -> ofType.isList() + else -> false + } + } + + fun modelName(info: IrFieldInfo, typeSet: TypeSet, rawTypename: String, isOther: Boolean): String { + val responseName = if (info.type.isList()) { + info.responseName.singularize() + } else { + info.responseName + } + val name = upperCamelCaseIgnoringNonLetters((typeSet - rawTypename).sorted() + responseName) + + return (if (isOther) "Other" else "") + name + } + + fun modelName(info: IrFieldInfo): String { + val responseName = if (info.type.isList()) { + info.responseName.singularize() + } else { + info.responseName + } + return upperCamelCaseIgnoringNonLetters(setOf(responseName)) + } + } +} diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt index 413da047a76..2b3972c361d 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt @@ -1,129 +1,13 @@ package com.apollographql.apollo3.compiler.codegen.java import com.apollographql.apollo3.compiler.PackageNameGenerator -import com.apollographql.apollo3.compiler.capitalizeFirstLetter +import com.apollographql.apollo3.compiler.codegen.CodegenLayout import com.apollographql.apollo3.compiler.escapeJavaReservedWord -import com.apollographql.apollo3.compiler.ir.IrFieldInfo -import com.apollographql.apollo3.compiler.ir.IrListType -import com.apollographql.apollo3.compiler.ir.IrNonNullType -import com.apollographql.apollo3.compiler.ir.IrOperation -import com.apollographql.apollo3.compiler.ir.IrType -import com.apollographql.apollo3.compiler.ir.TypeSet -import com.apollographql.apollo3.compiler.singularize -/** - * The central place where the names/packages of the different classes are decided and escape rules done. - * - * Inputs should always be GraphQL identifiers and outputs are valid Kotlin identifiers. - */ class JavaCodegenLayout( - private val packageNameGenerator: PackageNameGenerator, + packageNameGenerator: PackageNameGenerator, schemaPackageName: String, - private val useSemanticNaming: Boolean, -) { - private val typePackageName = "$schemaPackageName.type" - private val fragmentPackageName = "$schemaPackageName.fragment" - - // ------------------------ PackageNames --------------------------------- - - fun typePackageName() = typePackageName - fun typeAdapterPackageName() = "$typePackageName.adapter".stripDots() - - fun operationPackageName(filePath: String) = packageNameGenerator.packageName(filePath) - fun operationAdapterPackageName(filePath: String) = "${operationPackageName(filePath)}.adapter".stripDots() - fun operationResponseFieldsPackageName(filePath: String) = "${operationPackageName(filePath)}.selections".stripDots() - - @Suppress("UNUSED_PARAMETER") - fun fragmentPackageName(filePath: String?) = fragmentPackageName - - fun fragmentAdapterPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.adapter".stripDots() - fun fragmentResponseFieldsPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.selections".stripDots() - - private fun String.stripDots() = this.removePrefix(".").removeSuffix(".") - - // ------------------------ Names --------------------------------- - - internal fun compiledTypeName(name: String) = capitalizedIdentifier(name) - - internal fun enumName(name: String) = regularIdentifier(name) - - // We used to write upper case enum values but the server can define different values with different cases - // See https://github.com/apollographql/apollo-android/issues/3035 - internal fun enumValueName(name: String) = regularIdentifier(name) - internal fun enumResponseAdapterName(name: String) = enumName(name) + "_ResponseAdapter" - - internal fun operationName(operation: IrOperation): String { - val str = capitalizedIdentifier(operation.name) - - if (!useSemanticNaming) { - return str - } - - return if (str.endsWith(operation.operationType.name)) { - str - } else { - "$str${operation.operationType.name}" - } - } - - fun operationResponseAdapterWrapperName(operation: IrOperation) = operationName(operation) + "_ResponseAdapter" - fun operationVariablesAdapterName(operation: IrOperation) = operationName(operation) + "_VariablesAdapter" - fun operationSelectionsName(operation: IrOperation) = operationName(operation) + "Selections" - - internal fun fragmentName(name: String) = capitalizedIdentifier(name) + "Impl" - internal fun fragmentResponseAdapterWrapperName(name: String) = fragmentName(name) + "_ResponseAdapter" - internal fun fragmentVariablesAdapterName(name: String) = fragmentName(name) + "_VariablesAdapter" - internal fun fragmentSelectionsName(name: String) = regularIdentifier(name) + "Selections" - - internal fun inputObjectName(name: String) = capitalizedIdentifier(name) - internal fun inputObjectAdapterName(name: String) = capitalizedIdentifier(name) + "_InputAdapter" - - // variables keep the same case as their declared name - internal fun variableName(name: String) = regularIdentifier(name) - internal fun propertyName(name: String) = regularIdentifier(name) - internal fun schemaName() = "__Schema" - - // ------------------------ Helpers --------------------------------- - private fun regularIdentifier(name: String) = name.escapeJavaReservedWord() - private fun capitalizedIdentifier(name: String): String { - return name.capitalizeFirstLetter().escapeJavaReservedWord() - } - - fun rootSelectionsPropertyName() = "root" - - companion object { - private fun upperCamelCaseIgnoringNonLetters(strings: Collection): String { - return strings.map { - it.capitalizeFirstLetter() - }.joinToString("") - } - - private fun IrType.isList(): Boolean { - return when (this) { - is IrListType -> true - is IrNonNullType -> ofType.isList() - else -> false - } - } - - fun modelName(info: IrFieldInfo, typeSet: TypeSet, rawTypename: String, isOther: Boolean): String { - val responseName = if (info.type.isList()) { - info.responseName.singularize() - } else { - info.responseName - } - val name = upperCamelCaseIgnoringNonLetters((typeSet - rawTypename).sorted() + responseName) - - return (if (isOther) "Other" else "") + name - } - - fun modelName(info: IrFieldInfo): String { - val responseName = if (info.type.isList()) { - info.responseName.singularize() - } else { - info.responseName - } - return upperCamelCaseIgnoringNonLetters(setOf(responseName)) - } - } + useSemanticNaming: Boolean, +) : CodegenLayout(packageNameGenerator, schemaPackageName, useSemanticNaming) { + override fun escapeReservedWord(word: String): String = word.escapeJavaReservedWord() } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt index 3462f618e6e..25689920eda 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/model/ModelBuilder.kt @@ -1,13 +1,13 @@ package com.apollographql.apollo3.compiler.codegen.java.model import com.apollographql.apollo3.compiler.applyIf +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.codegen.java.JavaClassNames import com.apollographql.apollo3.compiler.codegen.java.JavaContext import com.apollographql.apollo3.compiler.codegen.java.adapter.toClassName import com.apollographql.apollo3.compiler.codegen.java.helpers.makeDataClassFromProperties import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDeprecation import com.apollographql.apollo3.compiler.codegen.java.helpers.maybeAddDescription -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.decapitalizeFirstLetter import com.apollographql.apollo3.compiler.ir.IrAccessor import com.apollographql.apollo3.compiler.ir.IrFragmentAccessor diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt index 109339ebe3e..7cc65ee4cbf 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt @@ -1,146 +1,17 @@ package com.apollographql.apollo3.compiler.codegen.kotlin import com.apollographql.apollo3.compiler.PackageNameGenerator -import com.apollographql.apollo3.compiler.capitalizeFirstLetter -import com.apollographql.apollo3.compiler.decapitalizeFirstLetter +import com.apollographql.apollo3.compiler.codegen.CodegenLayout import com.apollographql.apollo3.compiler.escapeKotlinReservedEnumValueNames import com.apollographql.apollo3.compiler.escapeKotlinReservedWord -import com.apollographql.apollo3.compiler.ir.IrFieldInfo -import com.apollographql.apollo3.compiler.ir.IrListType -import com.apollographql.apollo3.compiler.ir.IrNonNullType -import com.apollographql.apollo3.compiler.ir.IrOperation -import com.apollographql.apollo3.compiler.ir.IrType -import com.apollographql.apollo3.compiler.ir.TypeSet -import com.apollographql.apollo3.compiler.singularize -/** - * The central place where the names/packages of the different classes are decided and escape rules done. - * - * Inputs should always be GraphQL identifiers and outputs are valid Kotlin identifiers. - */ class KotlinCodegenLayout( - private val packageNameGenerator: PackageNameGenerator, + packageNameGenerator: PackageNameGenerator, schemaPackageName: String, - private val useSemanticNaming: Boolean, -) { - private val typePackageName = "$schemaPackageName.type" - private val fragmentPackageName = "$schemaPackageName.fragment" + useSemanticNaming: Boolean, +) : CodegenLayout(packageNameGenerator, schemaPackageName, useSemanticNaming) { - // ------------------------ FileNames --------------------------------- + override fun escapeReservedWord(word: String): String = word.escapeKotlinReservedWord() - internal fun fragmentModelsFileName(name: String) = capitalizedIdentifier(name) - - // ------------------------ PackageNames --------------------------------- - - fun typePackageName() = typePackageName - fun typeAdapterPackageName() = "$typePackageName.adapter".stripDots() - - fun operationPackageName(filePath: String) = packageNameGenerator.packageName(filePath) - fun operationAdapterPackageName(filePath: String) = "${operationPackageName(filePath)}.adapter".stripDots() - fun operationTestBuildersPackageName(filePath: String) = "${operationPackageName(filePath)}.test".stripDots() - fun operationResponseFieldsPackageName(filePath: String) = "${operationPackageName(filePath)}.selections".stripDots() - - @Suppress("UNUSED_PARAMETER") - fun fragmentPackageName(filePath: String?) = fragmentPackageName - - fun fragmentAdapterPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.adapter".stripDots() - fun fragmentResponseFieldsPackageName(filePath: String?) = "${fragmentPackageName(filePath)}.selections".stripDots() - - private fun String.stripDots() = this.removePrefix(".").removeSuffix(".") - - // ------------------------ Names --------------------------------- - - internal fun compiledTypeName(name: String) = capitalizedIdentifier(name) - - internal fun enumName(name: String) = regularIdentifier(name) - - // We used to write upper case enum values but the server can define different values with different cases - // See https://github.com/apollographql/apollo-android/issues/3035 - internal fun enumValueName(name: String) = regularIdentifier(name) internal fun sealedClassValueName(name: String) = name.escapeKotlinReservedEnumValueNames() - internal fun enumResponseAdapterName(name: String) = enumName(name) + "_ResponseAdapter" - - internal fun operationName(operation: IrOperation): String { - val str = capitalizedIdentifier(operation.name) - - if (!useSemanticNaming) { - return str - } - - return if (str.endsWith(operation.operationType.name)) { - str - } else { - "$str${operation.operationType.name}" - } - } - - fun operationResponseAdapterWrapperName(operation: IrOperation) = operationName(operation) + "_ResponseAdapter" - fun operationTestBuildersWrapperName(operation: IrOperation) = operationName(operation) + "_TestBuilder" - fun operationVariablesAdapterName(operation: IrOperation) = operationName(operation) + "_VariablesAdapter" - fun operationSelectionsName(operation: IrOperation) = operationName(operation) + "Selections" - - internal fun fragmentName(name: String) = capitalizedIdentifier(name) + "Impl" - internal fun fragmentResponseAdapterWrapperName(name: String) = fragmentName(name) + "_ResponseAdapter" - internal fun fragmentVariablesAdapterName(name: String) = fragmentName(name) + "_VariablesAdapter" - internal fun fragmentSelectionsName(name: String) = regularIdentifier(name) + "Selections" - - internal fun inputObjectName(name: String) = capitalizedIdentifier(name) - internal fun inputObjectAdapterName(name: String) = capitalizedIdentifier(name) + "_InputAdapter" - - // variables keep the same case as their declared name - internal fun variableName(name: String) = regularIdentifier(name) - internal fun propertyName(name: String) = regularIdentifier(name) - internal fun schemaName() = "__Schema" - - // ------------------------ Helpers --------------------------------- - private fun regularIdentifier(name: String) = name.escapeKotlinReservedWord() - private fun capitalizedIdentifier(name: String): String { - return name.capitalizeFirstLetter().escapeKotlinReservedWord() - } - - fun rootSelectionsPropertyName() = "root" - fun testBuilder(modelName: String): String { - return "${modelName}Builder" - } - - companion object { - fun upperCamelCaseIgnoringNonLetters(strings: Collection): String { - return strings.map { - it.capitalizeFirstLetter() - }.joinToString("") - } - fun lowerCamelCaseIgnoringNonLetters(strings: Collection): String { - return strings.map { - it.decapitalizeFirstLetter() - }.joinToString("") - } - - private fun IrType.isList(): Boolean { - return when (this) { - is IrListType -> true - is IrNonNullType -> ofType.isList() - else -> false - } - } - - fun modelName(info: IrFieldInfo, typeSet: TypeSet, rawTypename: String, isOther: Boolean): String { - val responseName = if (info.type.isList()) { - info.responseName.singularize() - } else { - info.responseName - } - val name = upperCamelCaseIgnoringNonLetters((typeSet - rawTypename).sorted() + responseName) - - return (if (isOther) "Other" else "") + name - } - - fun modelName(info: IrFieldInfo): String { - val responseName = if (info.type.isList()) { - info.responseName.singularize() - } else { - info.responseName - } - return upperCamelCaseIgnoringNonLetters(setOf(responseName)) - } - } } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt index 663666de9d1..77db3aabe97 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/model/ModelBuilder.kt @@ -2,7 +2,7 @@ package com.apollographql.apollo3.compiler.codegen.kotlin.model import com.apollographql.apollo3.compiler.TargetLanguage.KOTLIN_1_5 import com.apollographql.apollo3.compiler.applyIf -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.kotlin.adapter.from import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.makeDataClassFromProperties diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt index 164ad45b674..35eafcd22fa 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/OperationBasedModelGroupBuilder.kt @@ -15,8 +15,8 @@ import com.apollographql.apollo3.ast.GQLSelection import com.apollographql.apollo3.ast.Schema import com.apollographql.apollo3.ast.transformation.mergeTrivialInlineFragments import com.apollographql.apollo3.compiler.capitalizeFirstLetter -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.lowerCamelCaseIgnoringNonLetters -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.modelName +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.lowerCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.modelName import com.apollographql.apollo3.compiler.decapitalizeFirstLetter import com.apollographql.apollo3.compiler.escapeKotlinReservedWord diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt index 47b994f37a8..a2f26a50753 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ir/ResponseBasedModelGroupBuilder.kt @@ -10,8 +10,8 @@ import com.apollographql.apollo3.ast.GQLNamedType import com.apollographql.apollo3.ast.GQLNonNullType import com.apollographql.apollo3.ast.GQLSelection import com.apollographql.apollo3.ast.Schema -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.modelName -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinCodegenLayout.Companion.upperCamelCaseIgnoringNonLetters +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.modelName +import com.apollographql.apollo3.compiler.codegen.CodegenLayout.Companion.upperCamelCaseIgnoringNonLetters internal class ResponseBasedModelGroupBuilder( schema: Schema, diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql similarity index 90% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/TestOperation.graphql rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql index 6478af0b4f3..2cd21570c4a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/TestOperation.graphql +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql @@ -1,6 +1,6 @@ query TestQuery { yield: hero { - it: id + while: id name } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected similarity index 91% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected index 0b84f1b9cec..7ec5e049fe3 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/TestQuery.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords; +package com.example.reserved_keywords; import com.apollographql.apollo3.api.Adapter; import com.apollographql.apollo3.api.CompiledSelection; @@ -11,15 +11,15 @@ import com.apollographql.apollo3.api.CustomScalarAdapters; import com.apollographql.apollo3.api.ObjectAdapter; import com.apollographql.apollo3.api.Query; import com.apollographql.apollo3.api.json.JsonWriter; -import com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter; -import com.example.reserved_kotlin_keywords.selections.TestQuerySelections; +import com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter; +import com.example.reserved_keywords.selections.TestQuerySelections; import java.io.IOException; import java.lang.Override; import java.lang.String; import java.util.List; public class TestQuery implements Query { - public static final String OPERATION_ID = "da9796efa24977e73e9b865a993e83961235a63020ff989484d31097ab8e065b"; + public static final String OPERATION_ID = "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5"; /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -27,7 +27,7 @@ public class TestQuery implements Query { * * query TestQuery { * yield: hero { - * it: id + * while: id * name * } * objects: search(text: "abc") { @@ -37,7 +37,7 @@ public class TestQuery implements Query { * } * } * } */ - public static final String OPERATION_DOCUMENT = "query TestQuery { yield: hero { it: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }"; + public static final String OPERATION_DOCUMENT = "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }"; public static final String OPERATION_NAME = "TestQuery"; @@ -171,7 +171,7 @@ public class TestQuery implements Query { /** * The ID of the character */ - public String it; + public String while_; /** * The name of the character @@ -184,8 +184,8 @@ public class TestQuery implements Query { private transient volatile String $toString; - public Yield(String it, String name) { - this.it = it; + public Yield(String while_, String name) { + this.while_ = while_; this.name = name; } @@ -196,7 +196,7 @@ public class TestQuery implements Query { } if (o instanceof Yield) { Yield that = (Yield) o; - return ((this.it == null) ? (that.it == null) : this.it.equals(that.it)) + return ((this.while_ == null) ? (that.while_ == null) : this.while_.equals(that.while_)) &&((this.name == null) ? (that.name == null) : this.name.equals(that.name)); } return false; @@ -207,7 +207,7 @@ public class TestQuery implements Query { if (!$hashCodeMemoized) { int h = 1; h *= 1000003; - h ^= (it == null) ? 0 : it.hashCode(); + h ^= (while_ == null) ? 0 : while_.hashCode(); h *= 1000003; h ^= (name == null) ? 0 : name.hashCode(); $hashCode = h; @@ -220,7 +220,7 @@ public class TestQuery implements Query { public String toString() { if ($toString == null) { $toString = "Yield{" - + "it=" + it + ", " + + "while_=" + while_ + ", " + "name=" + name + "}"; } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected similarity index 89% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected index 80054cb0709..2bb87b4f116 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.adapter; +package com.example.reserved_keywords.adapter; import com.apollographql.apollo3.api.Adapter; import com.apollographql.apollo3.api.Adapters; @@ -18,7 +18,7 @@ import com.apollographql.apollo3.api.NullableAdapter; import com.apollographql.apollo3.api.ObjectAdapter; import com.apollographql.apollo3.api.json.JsonReader; import com.apollographql.apollo3.api.json.JsonWriter; -import com.example.reserved_kotlin_keywords.TestQuery; +import com.example.reserved_keywords.TestQuery; import java.io.IOException; import java.lang.Override; import java.lang.String; @@ -67,28 +67,28 @@ public class TestQuery_ResponseAdapter { public enum Yield implements Adapter { INSTANCE; - private static final List RESPONSE_NAMES = Arrays.asList("it", "name"); + private static final List RESPONSE_NAMES = Arrays.asList("while", "name"); @Override public TestQuery.Yield fromJson(JsonReader reader, CustomScalarAdapters customScalarAdapters) throws IOException { - String it = null; + String while_ = null; String name = null; loop: while(true) { switch (reader.selectName(RESPONSE_NAMES)) { - case 0: it = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; + case 0: while_ = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; case 1: name = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; default: break loop; } } - Assertions.checkFieldNotMissing(it, "it"); + Assertions.checkFieldNotMissing(while_, "while"); Assertions.checkFieldNotMissing(name, "name"); return new TestQuery.Yield( - it, + while_, name ); } @@ -96,8 +96,8 @@ public class TestQuery_ResponseAdapter { @Override public void toJson(JsonWriter writer, CustomScalarAdapters customScalarAdapters, TestQuery.Yield value) throws IOException { - writer.name("it"); - Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.it); + writer.name("while"); + Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.while_); writer.name("name"); Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.name); @@ -126,7 +126,7 @@ public class TestQuery_ResponseAdapter { reader.rewind(); TestQuery.OnCharacter onCharacter = null; if (BooleanExpressions.evaluate(new BooleanExpression.Element(new BPossibleTypes("Droid","Human")), Collections.emptySet(), __typename)) { - onCharacter = com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.OnCharacter.INSTANCE.fromJson(reader, customScalarAdapters); + onCharacter = com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.OnCharacter.INSTANCE.fromJson(reader, customScalarAdapters); } return new TestQuery.Object( @@ -142,7 +142,7 @@ public class TestQuery_ResponseAdapter { Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.__typename); if (value.onCharacter != null) { - com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.OnCharacter.INSTANCE.toJson(writer, customScalarAdapters, value.onCharacter); + com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.OnCharacter.INSTANCE.toJson(writer, customScalarAdapters, value.onCharacter); } } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected index b8a7ec7e15d..6d59d39e8e1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.selections; +package com.example.reserved_keywords.selections; import com.apollographql.apollo3.api.CompiledArgument; import com.apollographql.apollo3.api.CompiledField; @@ -12,14 +12,14 @@ import com.apollographql.apollo3.api.CompiledGraphQL; import com.apollographql.apollo3.api.CompiledListType; import com.apollographql.apollo3.api.CompiledNotNullType; import com.apollographql.apollo3.api.CompiledSelection; -import com.example.reserved_kotlin_keywords.type.Character; -import com.example.reserved_kotlin_keywords.type.SearchResult; +import com.example.reserved_keywords.type.Character; +import com.example.reserved_keywords.type.SearchResult; import java.util.Arrays; import java.util.List; public class TestQuerySelections { private static List yield = Arrays.asList( - new CompiledField.Builder("id", new CompiledNotNullType(CompiledGraphQL.CompiledIDType)).alias("it").build(), + new CompiledField.Builder("id", new CompiledNotNullType(CompiledGraphQL.CompiledIDType)).alias("while").build(), new CompiledField.Builder("name", new CompiledNotNullType(CompiledGraphQL.CompiledStringType)).build() ); diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Character.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Character.java.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Character.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Character.java.expected index da67aa5b08b..9b5c5dc8c8a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Character.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Character.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type; +package com.example.reserved_keywords.type; import com.apollographql.apollo3.api.InterfaceType; import java.util.Collections; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Droid.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Droid.java.expected similarity index 89% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Droid.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Droid.java.expected index 289b5bd61e4..77d1f1028f1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Droid.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Droid.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type; +package com.example.reserved_keywords.type; import com.apollographql.apollo3.api.ObjectType; import java.util.Arrays; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Human.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Human.java.expected similarity index 89% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Human.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Human.java.expected index f9a18ac9e3d..76ec88d3d6d 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Human.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Human.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type; +package com.example.reserved_keywords.type; import com.apollographql.apollo3.api.ObjectType; import java.util.Arrays; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/SearchResult.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/SearchResult.java.expected similarity index 85% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/SearchResult.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/SearchResult.java.expected index d5c49e92bec..12328967670 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/SearchResult.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/SearchResult.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type; +package com.example.reserved_keywords.type; import com.apollographql.apollo3.api.UnionType; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Starship.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Starship.java.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Starship.java.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Starship.java.expected index 16f6a0698d3..848a780edd3 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/java/operationBased/reserved_kotlin_keywords/type/Starship.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/type/Starship.java.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type; +package com.example.reserved_keywords.type; import com.apollographql.apollo3.api.ObjectType; import java.util.Collections; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected similarity index 83% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected index 29164d1ae3f..443433d8ff1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords +package com.example.reserved_keywords import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CompiledSelection @@ -11,8 +11,8 @@ import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.Query import com.apollographql.apollo3.api.json.JsonWriter import com.apollographql.apollo3.api.obj -import com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter -import com.example.reserved_kotlin_keywords.selections.TestQuerySelections +import com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter +import com.example.reserved_keywords.selections.TestQuerySelections import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -46,7 +46,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it: String, + public val while_: String, /** * The name of the character */ @@ -71,7 +71,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "da9796efa24977e73e9b865a993e83961235a63020ff989484d31097ab8e065b" + "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -79,7 +79,7 @@ public class TestQuery() : Query { * * query TestQuery { * yield: hero { - * it: id + * while: id * name * } * objects: search(text: "abc") { @@ -91,7 +91,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { it: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index 1e625c497ac..d990629b32e 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.adapter +package com.example.reserved_keywords.adapter import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters @@ -15,7 +15,7 @@ import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.nullable import com.apollographql.apollo3.api.obj import com.apollographql.apollo3.api.possibleTypes -import com.example.reserved_kotlin_keywords.TestQuery +import com.example.reserved_keywords.TestQuery import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -59,23 +59,23 @@ public object TestQuery_ResponseAdapter { } public object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("it", "name") + public val RESPONSE_NAMES: List = listOf("while", "name") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Yield { - var it: String? = null + var while_: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Yield( - it = it!!, + while_ = while_!!, name = name!! ) } @@ -85,8 +85,8 @@ public object TestQuery_ResponseAdapter { customScalarAdapters: CustomScalarAdapters, `value`: TestQuery.Yield ): Unit { - writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it) + writer.name("while") + StringAdapter.toJson(writer, customScalarAdapters, value.while_) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) @@ -114,7 +114,7 @@ public object TestQuery_ResponseAdapter { reader.rewind() var asCharacter: TestQuery.AsCharacter? = null if (possibleTypes("Droid","Human").evaluate(emptySet(), __typename)) { - asCharacter = com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.AsCharacter.fromJson(reader, + asCharacter = com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.AsCharacter.fromJson(reader, customScalarAdapters) } @@ -133,7 +133,7 @@ public object TestQuery_ResponseAdapter { StringAdapter.toJson(writer, customScalarAdapters, value.__typename) if (value.asCharacter != null) { - com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.AsCharacter.toJson(writer, + com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.AsCharacter.toJson(writer, customScalarAdapters, value.asCharacter) } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected similarity index 90% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected index 85d5017afa1..3e90903bda0 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.selections +package com.example.reserved_keywords.selections import com.apollographql.apollo3.api.CompiledArgument import com.apollographql.apollo3.api.CompiledField @@ -13,8 +13,8 @@ import com.apollographql.apollo3.api.CompiledSelection import com.apollographql.apollo3.api.CompiledStringType import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.notNull -import com.example.reserved_kotlin_keywords.type.Character -import com.example.reserved_kotlin_keywords.type.SearchResult +import com.example.reserved_keywords.type.Character +import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { @@ -22,7 +22,7 @@ public object TestQuerySelections { CompiledField.Builder( name = "id", type = CompiledIDType.notNull() - ).alias("it") + ).alias("while") .build(), CompiledField.Builder( name = "name", diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Character.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Character.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Character.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Character.kt.expected index 01dac52f36a..1437dc7c772 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Character.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Character.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.InterfaceType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Droid.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Droid.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Droid.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Droid.kt.expected index ba54886ce18..fb0e61f9e3a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Droid.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Droid.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Human.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Human.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Human.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Human.kt.expected index f3be2ee6ccc..469c4675faf 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Human.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Human.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/SearchResult.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/SearchResult.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/SearchResult.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/SearchResult.kt.expected index b6e84e55aa9..957a6a35376 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/SearchResult.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/SearchResult.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.UnionType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Starship.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Starship.kt.expected similarity index 85% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Starship.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Starship.kt.expected index 7a8428659ac..6f2dc7a6910 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Starship.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/type/Starship.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected similarity index 83% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected index 91cc1041c2b..825a14b2041 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords +package com.example.reserved_keywords import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CompiledSelection @@ -11,8 +11,8 @@ import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.Query import com.apollographql.apollo3.api.json.JsonWriter import com.apollographql.apollo3.api.obj -import com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter -import com.example.reserved_kotlin_keywords.selections.TestQuerySelections +import com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter +import com.example.reserved_keywords.selections.TestQuerySelections import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it: String, + public val while_: String, /** * The name of the character */ @@ -70,7 +70,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "da9796efa24977e73e9b865a993e83961235a63020ff989484d31097ab8e065b" + "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -78,7 +78,7 @@ public class TestQuery() : Query { * * query TestQuery { * yield: hero { - * it: id + * while: id * name * } * objects: search(text: "abc") { @@ -90,7 +90,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { it: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected similarity index 89% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index c606476f9cd..1473ffe8400 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.adapter +package com.example.reserved_keywords.adapter import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters @@ -15,7 +15,7 @@ import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.nullable import com.apollographql.apollo3.api.obj import com.apollographql.apollo3.api.possibleTypes -import com.example.reserved_kotlin_keywords.TestQuery +import com.example.reserved_keywords.TestQuery import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -58,23 +58,23 @@ public object TestQuery_ResponseAdapter { } private object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("it", "name") + public val RESPONSE_NAMES: List = listOf("while", "name") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var it: String? = null + var while_: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - it = it!!, + while_ = while_!!, name = name!! ) } @@ -84,8 +84,8 @@ public object TestQuery_ResponseAdapter { customScalarAdapters: CustomScalarAdapters, `value`: TestQuery.Data.Yield ): Unit { - writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it) + writer.name("while") + StringAdapter.toJson(writer, customScalarAdapters, value.while_) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) @@ -113,7 +113,7 @@ public object TestQuery_ResponseAdapter { reader.rewind() var onCharacter: TestQuery.Data.Object.OnCharacter? = null if (possibleTypes("Droid","Human").evaluate(emptySet(), __typename)) { - onCharacter = com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.Data.Object.OnCharacter.fromJson(reader, + onCharacter = com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.Data.Object.OnCharacter.fromJson(reader, customScalarAdapters) } @@ -132,7 +132,7 @@ public object TestQuery_ResponseAdapter { StringAdapter.toJson(writer, customScalarAdapters, value.__typename) if (value.onCharacter != null) { - com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter.Data.Object.OnCharacter.toJson(writer, + com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter.Data.Object.OnCharacter.toJson(writer, customScalarAdapters, value.onCharacter) } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected similarity index 90% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 85d5017afa1..3e90903bda0 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.selections +package com.example.reserved_keywords.selections import com.apollographql.apollo3.api.CompiledArgument import com.apollographql.apollo3.api.CompiledField @@ -13,8 +13,8 @@ import com.apollographql.apollo3.api.CompiledSelection import com.apollographql.apollo3.api.CompiledStringType import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.notNull -import com.example.reserved_kotlin_keywords.type.Character -import com.example.reserved_kotlin_keywords.type.SearchResult +import com.example.reserved_keywords.type.Character +import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { @@ -22,7 +22,7 @@ public object TestQuerySelections { CompiledField.Builder( name = "id", type = CompiledIDType.notNull() - ).alias("it") + ).alias("while") .build(), CompiledField.Builder( name = "name", diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Character.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Character.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Character.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Character.kt.expected index 01dac52f36a..1437dc7c772 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Character.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Character.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.InterfaceType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Droid.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Droid.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Droid.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Droid.kt.expected index ba54886ce18..fb0e61f9e3a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/type/Droid.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Droid.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Human.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Human.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Human.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Human.kt.expected index f3be2ee6ccc..469c4675faf 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Human.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Human.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/SearchResult.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/SearchResult.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/SearchResult.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/SearchResult.kt.expected index b6e84e55aa9..957a6a35376 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/SearchResult.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/SearchResult.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.UnionType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Starship.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Starship.kt.expected similarity index 85% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Starship.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Starship.kt.expected index 7a8428659ac..6f2dc7a6910 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Starship.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/type/Starship.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected similarity index 84% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected index 2a30401d85b..394e62e59bd 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords +package com.example.reserved_keywords import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CompiledSelection @@ -11,8 +11,8 @@ import com.apollographql.apollo3.api.CustomScalarAdapters import com.apollographql.apollo3.api.Query import com.apollographql.apollo3.api.json.JsonWriter import com.apollographql.apollo3.api.obj -import com.example.reserved_kotlin_keywords.adapter.TestQuery_ResponseAdapter -import com.example.reserved_kotlin_keywords.selections.TestQuerySelections +import com.example.reserved_keywords.adapter.TestQuery_ResponseAdapter +import com.example.reserved_keywords.selections.TestQuerySelections import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val it: String, + public val while_: String, /** * The name of the character */ @@ -75,7 +75,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "da9796efa24977e73e9b865a993e83961235a63020ff989484d31097ab8e065b" + "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -83,7 +83,7 @@ public class TestQuery() : Query { * * query TestQuery { * yield: hero { - * it: id + * while: id * name * } * objects: search(text: "abc") { @@ -95,7 +95,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { it: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected similarity index 94% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index b7dc3881094..48275d5b145 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/responseBased/reserved_kotlin_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.adapter +package com.example.reserved_keywords.adapter import com.apollographql.apollo3.api.Adapter import com.apollographql.apollo3.api.CustomScalarAdapters @@ -13,7 +13,7 @@ import com.apollographql.apollo3.api.json.JsonWriter import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.nullable import com.apollographql.apollo3.api.obj -import com.example.reserved_kotlin_keywords.TestQuery +import com.example.reserved_keywords.TestQuery import kotlin.String import kotlin.Unit import kotlin.collections.List @@ -55,23 +55,23 @@ public object TestQuery_ResponseAdapter { } private object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("it", "name") + public val RESPONSE_NAMES: List = listOf("while", "name") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var it: String? = null + var while_: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> it = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - it = it!!, + while_ = while_!!, name = name!! ) } @@ -81,8 +81,8 @@ public object TestQuery_ResponseAdapter { customScalarAdapters: CustomScalarAdapters, `value`: TestQuery.Data.Yield ): Unit { - writer.name("it") - StringAdapter.toJson(writer, customScalarAdapters, value.it) + writer.name("while") + StringAdapter.toJson(writer, customScalarAdapters, value.while_) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected similarity index 90% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 85d5017afa1..3e90903bda0 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.selections +package com.example.reserved_keywords.selections import com.apollographql.apollo3.api.CompiledArgument import com.apollographql.apollo3.api.CompiledField @@ -13,8 +13,8 @@ import com.apollographql.apollo3.api.CompiledSelection import com.apollographql.apollo3.api.CompiledStringType import com.apollographql.apollo3.api.list import com.apollographql.apollo3.api.notNull -import com.example.reserved_kotlin_keywords.type.Character -import com.example.reserved_kotlin_keywords.type.SearchResult +import com.example.reserved_keywords.type.Character +import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { @@ -22,7 +22,7 @@ public object TestQuerySelections { CompiledField.Builder( name = "id", type = CompiledIDType.notNull() - ).alias("it") + ).alias("while") .build(), CompiledField.Builder( name = "name", diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Character.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Character.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Character.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Character.kt.expected index 01dac52f36a..1437dc7c772 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Character.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Character.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.InterfaceType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Droid.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Droid.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Droid.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Droid.kt.expected index ba54886ce18..fb0e61f9e3a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Droid.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Droid.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Human.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Human.kt.expected similarity index 88% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Human.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Human.kt.expected index f3be2ee6ccc..469c4675faf 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/operationBased/reserved_kotlin_keywords/type/Human.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Human.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/SearchResult.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/SearchResult.kt.expected similarity index 87% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/SearchResult.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/SearchResult.kt.expected index b6e84e55aa9..957a6a35376 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/SearchResult.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/SearchResult.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.UnionType diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Starship.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Starship.kt.expected similarity index 85% rename from apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Starship.kt.expected rename to apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Starship.kt.expected index 7a8428659ac..6f2dc7a6910 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_kotlin_keywords/kotlin/compat/reserved_kotlin_keywords/type/Starship.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/type/Starship.kt.expected @@ -3,7 +3,7 @@ // // This class was automatically generated by Apollo GraphQL version '$VERSION'. // -package com.example.reserved_kotlin_keywords.type +package com.example.reserved_keywords.type import com.apollographql.apollo3.api.ObjectType From bc1aa75283549ead8f067e4bee39b0543beeeaf7 Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 1 Dec 2021 11:56:43 +0100 Subject: [PATCH 3/7] Do not manually escape Kotlin reserved keywords, rely on KotlinPoet instead --- .../apollo3/compiler/ReservedKeywords.kt | 10 +- .../codegen/kotlin/adapter/AdapterCommon.kt | 22 +- .../antlr_tokens/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../src/test/graphql/com/example/measurements | 460 +++++++++--------- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- 13 files changed, 273 insertions(+), 275 deletions(-) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt index 258c918996e..73cf28691e8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt @@ -10,13 +10,9 @@ private val JAVA_RESERVED_WORDS = arrayOf( "transient", "try", "true", "void", "volatile", "while" ) -// Reference: -// https://kotlinlang.org/docs/keyword-reference.html#operators-and-special-symbols -// Note: "yield" is not in this reference, but is in fact reserved (https://github.com/apollographql/apollo-android/issues/1957) -private val KOTLIN_RESERVED_WORDS = arrayOf( - "as", "break", "class", "continue", "do", "else", "false", "for", "fun", "if", "in", "interface", "is", "null", "object", "package", - "return", "super", "this", "throw", "true", "try", "typealias", "typeof", "val", "var", "when", "while", "yield" -) +// Note: reserved keywords escaping is handled by KotlinPoet, but "yield" is actually missing from its list, +// so we handle it ourselves (see https://github.com/apollographql/apollo-android/issues/1957) +private val KOTLIN_RESERVED_WORDS = arrayOf("yield") // Reference: // https://kotlinlang.org/docs/enum-classes.html#working-with-enum-constants:~:text=properties%20for%20obtaining%20its%20name%20and%20position diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/adapter/AdapterCommon.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/adapter/AdapterCommon.kt index f8feb1353ee..c0f15ce949f 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/adapter/AdapterCommon.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/adapter/AdapterCommon.kt @@ -52,7 +52,7 @@ internal fun readFromResponseCodeBlock( } CodeBlock.of( - "var·%L:·%T·=·%L", + "var·%N:·%T·=·%L", context.layout.variableName(property.info.responseName), context.resolver.resolveIrType(property.info.type).copy(nullable = !property.info.type.isOptional()), variableInitializer @@ -68,7 +68,7 @@ internal fun readFromResponseCodeBlock( .add( regularProperties.mapIndexed { index, property -> CodeBlock.of( - "%L·->·%L·=·%L.$fromJson($reader, $customScalarAdapters)", + "%L·->·%N·=·%L.$fromJson($reader, $customScalarAdapters)", index, context.layout.variableName(property.info.responseName), context.resolver.adapterInitializer(property.info.type, property.requiresBuffering) @@ -103,7 +103,7 @@ internal fun readFromResponseCodeBlock( .apply { if (property.condition != BooleanExpression.True) { add( - "var·%L:·%T·=·null\n", + "var·%N:·%T·=·null\n", context.layout.variableName(property.info.responseName), context.resolver.resolveIrType(property.info.type).copy(nullable = !property.info.type.isOptional()), ) @@ -140,7 +140,7 @@ internal fun readFromResponseCodeBlock( "" } CodeBlock.of( - "%L·=·%L%L", + "%N·=·%N%L", context.layout.propertyName(property.info.responseName), context.layout.variableName(property.info.responseName), maybeAssertNotNull @@ -183,8 +183,9 @@ private fun IrProperty.writeToResponseCodeBlock(context: KotlinContext): CodeBlo val adapterInitializer = context.resolver.adapterInitializer(info.type, requiresBuffering) builder.addStatement("${writer}.name(%S)", info.responseName) builder.addStatement( - "%L.${Identifier.toJson}($writer, $customScalarAdapters, $value.$propertyName)", - adapterInitializer + "%L.${Identifier.toJson}($writer, $customScalarAdapters, $value.%N)", + adapterInitializer, + propertyName, ) } else { val adapterInitializer = context.resolver.resolveModelAdapter(info.type.modelPath()) @@ -193,11 +194,12 @@ private fun IrProperty.writeToResponseCodeBlock(context: KotlinContext): CodeBlo * Output types do not distinguish between null and absent */ if (this.info.type !is IrNonNullType) { - builder.beginControlFlow("if·($value.$propertyName·!=·null)") + builder.beginControlFlow("if·($value.%N·!=·null)", propertyName) } builder.addStatement( - "%L.${Identifier.toJson}($writer, $customScalarAdapters, $value.$propertyName)", - adapterInitializer + "%L.${Identifier.toJson}($writer, $customScalarAdapters, $value.%N)", + adapterInitializer, + propertyName, ) if (this.info.type !is IrNonNullType) { builder.endControlFlow() @@ -225,4 +227,4 @@ internal fun CodeBlock.obj(buffered: Boolean): CodeBlock { MemberName("com.apollographql.apollo3.api", "obj"), params ).build() -} \ No newline at end of file +} diff --git a/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/TestQuery.kt.expected index 5f3d33e87a3..ada024319d3 100644 --- a/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/TestQuery.kt.expected @@ -43,7 +43,7 @@ public data class TestQuery( ) : Query.Data { public data class TypeWithGraphQLKeywords( public val on: String?, - public val null_: String?, + public val `null`: String?, public val alias: String? ) } diff --git a/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/adapter/TestQuery_ResponseAdapter.kt.expected index d3f6cfbe429..12f1c32a733 100644 --- a/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/antlr_tokens/kotlin/responseBased/antlr_tokens/adapter/TestQuery_ResponseAdapter.kt.expected @@ -54,13 +54,13 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.TypeWithGraphQLKeywords { var on: String? = null - var null_: String? = null + var `null`: String? = null var alias: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { 0 -> on = NullableStringAdapter.fromJson(reader, customScalarAdapters) - 1 -> null_ = NullableStringAdapter.fromJson(reader, customScalarAdapters) + 1 -> `null` = NullableStringAdapter.fromJson(reader, customScalarAdapters) 2 -> alias = NullableStringAdapter.fromJson(reader, customScalarAdapters) else -> break } @@ -68,7 +68,7 @@ public object TestQuery_ResponseAdapter { return TestQuery.Data.TypeWithGraphQLKeywords( on = on, - null_ = null_, + `null` = `null`, alias = alias ) } @@ -82,7 +82,7 @@ public object TestQuery_ResponseAdapter { NullableStringAdapter.toJson(writer, customScalarAdapters, value.on) writer.name("null") - NullableStringAdapter.toJson(writer, customScalarAdapters, value.null_) + NullableStringAdapter.toJson(writer, customScalarAdapters, value.`null`) writer.name("alias") NullableStringAdapter.toJson(writer, customScalarAdapters, value.alias) diff --git a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected index 17ce0c8817b..7b3697f662a 100644 --- a/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/case_sensitive_enum/kotlin/responseBased/case_sensitive_enum/adapter/TestQuery_ResponseAdapter.kt.expected @@ -23,17 +23,17 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var enum: Enum? = null + var `enum`: Enum? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> enum = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) + 0 -> `enum` = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data( - enum = enum + `enum` = `enum` ) } @@ -43,7 +43,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("enum") - Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum) + Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.`enum`) } } } diff --git a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected index 82da00821a3..ef434058e08 100644 --- a/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/enums_as_sealed/kotlin/responseBased/enums_as_sealed/adapter/TestQuery_ResponseAdapter.kt.expected @@ -23,17 +23,17 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var enum: Enum? = null + var `enum`: Enum? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> enum = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) + 0 -> `enum` = Enum_ResponseAdapter.nullable().fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data( - enum = enum + `enum` = `enum` ) } @@ -43,7 +43,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("enum") - Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.enum) + Enum_ResponseAdapter.nullable().toJson(writer, customScalarAdapters, value.`enum`) } } } diff --git a/apollo-compiler/src/test/graphql/com/example/measurements b/apollo-compiler/src/test/graphql/com/example/measurements index e19c436d39f..464556f8c96 100644 --- a/apollo-compiler/src/test/graphql/com/example/measurements +++ b/apollo-compiler/src/test/graphql/com/example/measurements @@ -1,232 +1,232 @@ Test: Total LOC: Codegen (ms): Compilation (ms): -aggregate all 146069 3.683314481s 1m 47.636010028s -aggregate responseBased 39008 1.443916192s 47.533241368s -aggregate operationBased 81192 1.502899031s 35.116954126s -aggregate compat 25869 736.499258ms 24.985814534s +aggregate all 146069 3.527270560s 1m 47.394797915s +aggregate responseBased 39008 1.394195753s 46.762166169s +aggregate operationBased 81192 1.402876125s 34.636349629s +aggregate compat 25869 730.198682ms 25.996282117s -kotlin-responseBased-fragment_with_inline_fragment 2188 81 1.974247754s -java-operationBased-nested_named_fragments 1739 13 155.739168ms -java-operationBased-fragment_with_inline_fragment 1703 22 202.380782ms -java-operationBased-union_inline_fragments 1523 9 120.105131ms -java-operationBased-inline_fragment_intersection 1499 25 152.998193ms -java-operationBased-unique_type_name 1497 14 122.327643ms -java-operationBased-root_query_fragment_with_nested_fragments 1437 16 143.624494ms -kotlin-responseBased-nested_named_fragments 1435 62 1.020974748s -java-operationBased-mutation_create_review 1351 18 179.770484ms -kotlin-compat-fragment_with_inline_fragment 1323 54 1.092160135s -java-operationBased-__schema 1314 68 935.367380ms -java-operationBased-named_fragment_delegate 1312 11 135.682654ms -java-operationBased-named_fragment_with_variables 1223 15 151.681397ms -kotlin-compat-nested_named_fragments 1203 28 745.395899ms -kotlin-responseBased-unique_type_name 1185 32 629.033855ms -java-operationBased-nested_conditional_inline 1181 11 114.874038ms -kotlin-responseBased-named_fragment_delegate 1166 32 757.830844ms -java-operationBased-input_object_type 1162 15 191.884306ms -java-operationBased-nested_field_with_multiple_fieldsets 1152 7 107.397239ms -java-operationBased-mutation_create_review_semantic_naming 1147 14 108.375731ms -java-operationBased-fragment_used_twice 1144 18 169.782321ms -java-operationBased-multiple_fragments 1129 12 120.522313ms -java-operationBased-two_heroes_with_friends 1103 6 95.346522ms -java-operationBased-inline_fragment_merge_fields 1102 9 173.652235ms -kotlin-operationBased-nested_named_fragments 1079 23 656.296453ms -kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 26 882.136461ms -kotlin-responseBased-inline_fragment_intersection 1073 22 841.716489ms -kotlin-operationBased-fragment_with_inline_fragment 1051 26 1.025132227s -kotlin-compat-inline_fragment_intersection 1040 30 869.997249ms -java-operationBased-named_fragment_inside_inline_fragment 1037 12 115.317475ms -java-operationBased-fragments_with_type_condition 1003 15 183.653463ms -kotlin-compat-unique_type_name 994 21 568.194587ms -java-operationBased-root_query_inline_fragment 982 7 216.738005ms -kotlin-operationBased-inline_fragment_intersection 976 51 1.290619354s -kotlin-operationBased-union_inline_fragments 974 21 754.377351ms -kotlin-responseBased-union_inline_fragments 971 21 561.918582ms -kotlin-responseBased-__schema 969 225 6.053858327s -kotlin-compat-root_query_fragment_with_nested_fragments 965 19 643.147175ms -kotlin-responseBased-fragment_used_twice 952 29 965.967650ms -kotlin-operationBased-unique_type_name 938 15 613.579705ms -java-operationBased-simple_fragment_with_inline_fragments 931 7 94.111900ms -kotlin-compat-union_inline_fragments 928 14 597.082512ms -java-operationBased-inline_fragments_with_friends 923 17 159.433486ms -java-operationBased-fragment_spread_with_nested_fields 916 19 161.162094ms -kotlin-responseBased-mutation_create_review 899 24 862.794508ms -kotlin-responseBased-simple_fragment_with_inline_fragments 896 19 552.113303ms -kotlin-responseBased-fragments_with_type_condition 894 24 690.834391ms -kotlin-responseBased-nested_conditional_inline 892 16 841.727087ms -java-operationBased-fragment_spread_with_include_directive 888 18 179.990791ms -kotlin-responseBased-named_fragment_with_variables 879 21 703.070802ms -kotlin-operationBased-root_query_fragment_with_nested_fragments 876 16 626.827824ms -kotlin-responseBased-multiple_fragments 875 29 596.084050ms -java-operationBased-simple_fragment 865 12 113.243634ms -kotlin-compat-named_fragment_delegate 840 18 693.291361ms -kotlin-compat-fragment_used_twice 835 30 1.321887815s -java-operationBased-simple_union 834 12 101.412032ms -kotlin-compat-named_fragment_with_variables 833 23 664.802903ms -java-operationBased-fragments_same_type_condition 814 13 172.415415ms -kotlin-compat-nested_conditional_inline 812 17 674.746981ms -java-operationBased-hero_details 810 8 119.367084ms -java-operationBased-deprecated_merged_field 803 24 173.418647ms -kotlin-operationBased-named_fragment_delegate 803 42 554.291375ms -java-operationBased-fieldset_with_multiple_super 797 17 176.656345ms -java-operationBased-not_all_combinations_are_needed 795 7 104.421458ms -java-operationBased-simple_inline_fragment 792 5 92.489479ms -java-operationBased-inline_fragment_with_include_directive 784 9 108.628089ms -java-operationBased-test_inline 761 4 83.141330ms -kotlin-responseBased-input_object_type 755 20 855.655933ms -java-operationBased-union_fragment 752 6 104.575665ms -java-operationBased-inline_fragment_inside_inline_fragment 749 15 167.864284ms -kotlin-compat-multiple_fragments 748 18 601.331645ms -kotlin-operationBased-named_fragment_with_variables 746 17 558.808046ms -kotlin-operationBased-nested_conditional_inline 746 28 609.362695ms -kotlin-responseBased-mutation_create_review_semantic_naming 741 33 850.299600ms -kotlin-responseBased-fragment_spread_with_nested_fields 723 30 910.117815ms -kotlin-responseBased-nested_field_with_multiple_fieldsets 716 11 713.020306ms -kotlin-compat-fragments_with_type_condition 709 17 630.891015ms -kotlin-operationBased-fragment_used_twice 701 26 807.999349ms -java-operationBased-named_fragment_without_implementation 681 7 132.970128ms -kotlin-operationBased-nested_field_with_multiple_fieldsets 677 13 534.709937ms -java-operationBased-fragment_with_multiple_fieldsets 675 19 147.149313ms -java-operationBased-hero_details_semantic_naming 675 9 108.483777ms -kotlin-responseBased-simple_fragment 674 14 524.018157ms -kotlin-operationBased-inline_fragment_merge_fields 667 16 574.163005ms -kotlin-responseBased-two_heroes_with_friends 661 13 537.514156ms -kotlin-operationBased-multiple_fragments 659 17 568.018408ms -java-operationBased-path_vs_flat_accessors 658 5 86.707438ms -kotlin-compat-simple_fragment_with_inline_fragments 639 11 524.190694ms -java-operationBased-reserved_kotlin_keywords 635 7 139.460804ms -java-operationBased-typename_always_first 630 4 79.507036ms -kotlin-responseBased-inline_fragments_with_friends 626 14 719.684981ms -kotlin-operationBased-root_query_inline_fragment 623 12 604.679603ms -kotlin-operationBased-fragments_with_type_condition 621 21 726.107561ms -kotlin-operationBased-named_fragment_inside_inline_fragment 618 20 787.838555ms -kotlin-compat-nested_field_with_multiple_fieldsets 616 11 472.610719ms -kotlin-compat-named_fragment_inside_inline_fragment 613 33 904.925649ms -java-operationBased-interface_on_interface 610 7 98.826297ms -kotlin-compat-simple_fragment 610 11 439.060592ms -kotlin-compat-inline_fragments_with_friends 606 63 619.303947ms -java-operationBased-introspection_query 605 5 89.893583ms -kotlin-responseBased-deprecated_merged_field 602 26 947.659980ms -kotlin-responseBased-simple_union 601 12 459.683513ms -kotlin-responseBased-root_query_inline_fragment 595 14 1.036581624s -kotlin-compat-fragment_spread_with_nested_fields 594 14 724.027529ms -kotlin-responseBased-named_fragment_inside_inline_fragment 589 24 547.141504ms -java-operationBased-root_query_fragment 584 13 119.430720ms -kotlin-compat-fragment_spread_with_include_directive 583 24 894.805542ms -kotlin-operationBased-inline_fragments_with_friends 573 12 570.802068ms -java-operationBased-input_object_variable_and_argument 569 8 105.603278ms -java-operationBased-interface_always_nested 565 6 96.530145ms -kotlin-operationBased-simple_fragment_with_inline_fragments 565 13 564.219419ms -kotlin-compat-root_query_inline_fragment 563 16 548.041672ms -kotlin-operationBased-fragment_spread_with_nested_fields 554 19 705.879160ms -kotlin-responseBased-fragments_same_type_condition 553 22 748.092577ms -java-operationBased-deprecation 544 10 123.613584ms -kotlin-compat-simple_union 542 13 379.636056ms -kotlin-compat-inline_fragment_with_include_directive 540 9 539.390091ms -kotlin-operationBased-fragment_spread_with_include_directive 539 17 923.920229ms -java-operationBased-recursive_selection 538 7 102.736220ms -java-operationBased-hero_with_review 529 6 90.410073ms -kotlin-compat-union_fragment 529 8 421.097392ms -kotlin-compat-deprecated_merged_field 528 26 879.361643ms -kotlin-responseBased-test_inline 527 15 405.728591ms -kotlin-compat-not_all_combinations_are_needed 526 12 458.149270ms -kotlin-compat-fragments_same_type_condition 524 13 544.994323ms -kotlin-operationBased-simple_fragment 522 19 601.814664ms -kotlin-compat-inline_fragment_inside_inline_fragment 521 20 610.003503ms -kotlin-responseBased-fragment_with_multiple_fieldsets 512 16 647.853969ms -kotlin-compat-fieldset_with_multiple_super 511 14 745.453429ms -kotlin-responseBased-union_fragment 508 11 395.252527ms -java-operationBased-field_with_include_directive 507 6 108.142266ms -java-operationBased-hero_name_query_long_name 504 9 106.640110ms -java-operationBased-variable_default_value 504 4 79.160546ms -java-operationBased-hero_name 503 13 106.690824ms -kotlin-operationBased-simple_union 498 9 361.132368ms -kotlin-operationBased-inline_fragment_inside_inline_fragment 489 13 670.731368ms -kotlin-operationBased-inline_fragment_with_include_directive 489 10 498.827963ms -kotlin-responseBased-inline_fragment_merge_fields 488 17 480.214835ms -kotlin-responseBased-hero_details 487 12 537.438449ms -kotlin-compat-inline_fragment_merge_fields 486 14 611.792960ms -java-operationBased-custom_scalar_type 484 10 154.874890ms -kotlin-operationBased-fieldset_with_multiple_super 483 17 828.253049ms -kotlin-responseBased-inline_fragment_inside_inline_fragment 482 10 539.026671ms -kotlin-compat-named_fragment_without_implementation 481 9 467.421639ms -kotlin-operationBased-fragments_same_type_condition 480 12 508.503265ms -java-operationBased-optional 479 4 92.174863ms -kotlin-operationBased-simple_inline_fragment 478 13 405.528058ms -kotlin-operationBased-union_fragment 478 9 431.918369ms -kotlin-operationBased-not_all_combinations_are_needed 475 10 598.350989ms -kotlin-operationBased-deprecated_merged_field 472 24 891.456141ms -java-operationBased-inline_fragment_for_non_optional_field 471 5 147.403389ms -kotlin-responseBased-fieldset_with_multiple_super 470 17 837.155318ms -kotlin-responseBased-named_fragment_without_implementation 470 15 394.577763ms -kotlin-responseBased-simple_inline_fragment 468 8 401.910741ms -kotlin-compat-test_inline 468 11 457.372883ms -java-operationBased-inline_fragment_type_coercion 466 4 130.089045ms -java-operationBased-java8annotation 464 9 90.834770ms -java-operationBased-two_heroes_unique 459 3 77.032603ms -kotlin-compat-fragment_with_multiple_fieldsets 448 13 450.971854ms -kotlin-responseBased-not_all_combinations_are_needed 447 9 440.914071ms -kotlin-operationBased-test_inline 445 9 427.723620ms -kotlin-responseBased-reserved_kotlin_keywords 444 11 568.357034ms -kotlin-compat-simple_inline_fragment 444 9 466.057618ms -kotlin-operationBased-named_fragment_without_implementation 437 9 477.845161ms -kotlin-responseBased-path_vs_flat_accessors 422 8 386.171430ms -kotlin-compat-reserved_kotlin_keywords 421 9 395.092922ms -kotlin-operationBased-reserved_kotlin_keywords 414 10 390.753681ms -java-operationBased-starships 411 3 73.402ms -kotlin-responseBased-hero_details_semantic_naming 409 19 457.246418ms -kotlin-compat-path_vs_flat_accessors 405 6 476.185657ms -kotlin-responseBased-interface_on_interface 400 7 471.685435ms -java-operationBased-subscriptions 400 5 79.025275ms -kotlin-responseBased-typename_always_first 400 46 355.490895ms -kotlin-operationBased-fragment_with_multiple_fieldsets 398 12 695.642117ms -java-operationBased-antlr_tokens 397 21 175.437700ms -kotlin-operationBased-path_vs_flat_accessors 391 8 372.453930ms -kotlin-responseBased-root_query_fragment 388 8 417.917967ms -kotlin-responseBased-input_object_variable_and_argument 387 12 586.170204ms -kotlin-operationBased-typename_always_first 387 6 324.349975ms -kotlin-compat-typename_always_first 387 14 403.396957ms -kotlin-compat-root_query_fragment 386 7 359.874393ms -kotlin-compat-interface_on_interface 378 8 353.275181ms -kotlin-responseBased-hero_name 376 7 437.809322ms -java-operationBased-arguments_hardcoded 374 7 138.967468ms -kotlin-operationBased-interface_on_interface 371 8 509.813894ms -kotlin-responseBased-interface_always_nested 368 8 431.286936ms -kotlin-responseBased-hero_with_review 358 10 455.590512ms -java-operationBased-merged_include 354 3 83.027588ms -kotlin-compat-interface_always_nested 353 8 409.396006ms -java-operationBased-operation_id_generator 353 7 106.275301ms -kotlin-responseBased-deprecation 350 18 691.849302ms -kotlin-responseBased-hero_name_query_long_name 348 9 536.133133ms -kotlin-compat-hero_name 344 6 418.189917ms -kotlin-operationBased-root_query_fragment 342 10 398.495256ms -java-operationBased-case_sensitive_enum 341 5 122.569572ms -java-operationBased-enum_field 341 7 137.031503ms -java-operationBased-enums_as_sealed 341 10 94.663923ms -kotlin-responseBased-custom_scalar_type 339 16 891.796752ms -kotlin-operationBased-interface_always_nested 339 7 543.604506ms -java-operationBased-nonnull 335 3 71.681798ms -kotlin-responseBased-inline_fragment_for_non_optional_field 332 8 522.784160ms -kotlin-responseBased-introspection_query 332 7 353.795127ms -kotlin-responseBased-field_with_include_directive 318 12 534.045236ms -kotlin-responseBased-variable_default_value 317 8 454.820909ms -kotlin-operationBased-hero_name 316 8 465.687250ms -kotlin-responseBased-inline_fragment_type_coercion 314 8 401.729327ms -kotlin-compat-inline_fragment_for_non_optional_field 303 8 562.134132ms -kotlin-responseBased-recursive_selection 302 6 422.446653ms -kotlin-responseBased-optional 298 11 548.775470ms -kotlin-compat-inline_fragment_type_coercion 290 5 346.671087ms -kotlin-operationBased-inline_fragment_for_non_optional_field 286 6 531.645300ms -kotlin-operationBased-inline_fragment_type_coercion 276 9 418.781459ms -kotlin-responseBased-two_heroes_unique 273 5 287.765393ms -kotlin-responseBased-java8annotation 266 6 434.844080ms -kotlin-responseBased-starships 263 5 321.700933ms -kotlin-responseBased-antlr_tokens 256 47 831.538072ms -kotlin-responseBased-subscriptions 252 5 283.110486ms -kotlin-responseBased-arguments_hardcoded 245 22 785.651083ms -kotlin-responseBased-enums_as_sealed 225 13 514.517686ms -kotlin-responseBased-operation_id_generator 207 6 389.207761ms -kotlin-responseBased-merged_include 206 5 281.955124ms -kotlin-responseBased-nonnull 191 7 273.083341ms -kotlin-responseBased-case_sensitive_enum 190 10 634.559034ms -kotlin-responseBased-enum_field 189 10 495.058499ms -kotlin-responseBased-empty 0 0 210.495722ms -java-operationBased-empty 0 0 8.882us \ No newline at end of file +kotlin-responseBased-fragment_with_inline_fragment 2188 79 1.514746331s +java-operationBased-nested_named_fragments 1739 16 238.624710ms +java-operationBased-fragment_with_inline_fragment 1703 17 154.943475ms +java-operationBased-union_inline_fragments 1523 9 139.652433ms +java-operationBased-inline_fragment_intersection 1499 15 159.305914ms +java-operationBased-unique_type_name 1497 11 136.039757ms +java-operationBased-root_query_fragment_with_nested_fragments 1437 10 132.768144ms +kotlin-responseBased-nested_named_fragments 1435 38 1.098481838s +java-operationBased-mutation_create_review 1351 9 146.244882ms +kotlin-compat-fragment_with_inline_fragment 1323 29 1.127864566s +java-operationBased-__schema 1314 78 823.799153ms +java-operationBased-named_fragment_delegate 1312 8 136.387006ms +java-operationBased-named_fragment_with_variables 1223 22 157.735470ms +kotlin-compat-nested_named_fragments 1203 23 972.748373ms +kotlin-responseBased-unique_type_name 1185 29 799.324778ms +java-operationBased-nested_conditional_inline 1181 20 145.762985ms +kotlin-responseBased-named_fragment_delegate 1166 44 818.908907ms +java-operationBased-input_object_type 1162 8 129.160314ms +java-operationBased-nested_field_with_multiple_fieldsets 1152 13 149.195101ms +java-operationBased-mutation_create_review_semantic_naming 1147 9 151.024526ms +java-operationBased-fragment_used_twice 1144 11 143.723288ms +java-operationBased-multiple_fragments 1129 10 144.698615ms +java-operationBased-two_heroes_with_friends 1103 13 179.474956ms +java-operationBased-inline_fragment_merge_fields 1102 10 126.375186ms +kotlin-operationBased-nested_named_fragments 1079 28 883.718647ms +kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 25 650.895769ms +kotlin-responseBased-inline_fragment_intersection 1073 28 849.069583ms +kotlin-operationBased-fragment_with_inline_fragment 1051 24 947.435012ms +kotlin-compat-inline_fragment_intersection 1040 16 950.141948ms +java-operationBased-named_fragment_inside_inline_fragment 1037 8 118.707293ms +java-operationBased-fragments_with_type_condition 1003 8 105.244390ms +kotlin-compat-unique_type_name 994 17 797.182552ms +java-operationBased-root_query_inline_fragment 982 13 130.264701ms +kotlin-operationBased-inline_fragment_intersection 976 35 783.102790ms +kotlin-operationBased-union_inline_fragments 974 21 827.762393ms +kotlin-responseBased-union_inline_fragments 971 21 677.823693ms +kotlin-responseBased-__schema 969 196 5.953447004s +kotlin-compat-root_query_fragment_with_nested_fragments 965 17 692.050409ms +kotlin-responseBased-fragment_used_twice 952 27 860.730175ms +kotlin-operationBased-unique_type_name 938 23 697.659935ms +java-operationBased-simple_fragment_with_inline_fragments 931 8 129.796120ms +kotlin-compat-union_inline_fragments 928 17 705.461449ms +java-operationBased-inline_fragments_with_friends 923 6 139.220986ms +java-operationBased-fragment_spread_with_nested_fields 916 11 160.557340ms +kotlin-responseBased-mutation_create_review 899 17 781.535101ms +kotlin-responseBased-simple_fragment_with_inline_fragments 896 22 571.165299ms +kotlin-responseBased-fragments_with_type_condition 894 21 666.926452ms +kotlin-responseBased-nested_conditional_inline 892 20 870.632830ms +java-operationBased-fragment_spread_with_include_directive 888 10 137.212097ms +kotlin-responseBased-named_fragment_with_variables 879 48 1.061199224s +kotlin-operationBased-root_query_fragment_with_nested_fragments 876 17 645.425334ms +kotlin-responseBased-multiple_fragments 875 27 662.494257ms +java-operationBased-simple_fragment 865 7 112.543165ms +kotlin-compat-named_fragment_delegate 840 22 592.785070ms +kotlin-compat-fragment_used_twice 835 19 730.216170ms +java-operationBased-simple_union 834 9 119.709775ms +kotlin-compat-named_fragment_with_variables 833 25 994.687814ms +java-operationBased-fragments_same_type_condition 814 8 125.504164ms +kotlin-compat-nested_conditional_inline 812 16 779.452237ms +java-operationBased-hero_details 810 6 112.422164ms +java-operationBased-deprecated_merged_field 803 14 138.063929ms +kotlin-operationBased-named_fragment_delegate 803 27 666.124884ms +java-operationBased-fieldset_with_multiple_super 797 8 115.521405ms +java-operationBased-not_all_combinations_are_needed 795 6 108.952674ms +java-operationBased-simple_inline_fragment 792 12 197.068974ms +java-operationBased-inline_fragment_with_include_directive 784 5 108.904721ms +java-operationBased-test_inline 761 6 102.865165ms +kotlin-responseBased-input_object_type 755 22 680.491098ms +java-operationBased-union_fragment 752 7 120.423961ms +java-operationBased-inline_fragment_inside_inline_fragment 749 8 108.493670ms +kotlin-compat-multiple_fragments 748 16 554.890182ms +kotlin-operationBased-named_fragment_with_variables 746 24 815.454782ms +kotlin-operationBased-nested_conditional_inline 746 17 641.347540ms +kotlin-responseBased-mutation_create_review_semantic_naming 741 14 673.407031ms +kotlin-responseBased-fragment_spread_with_nested_fields 723 30 720.609330ms +kotlin-responseBased-nested_field_with_multiple_fieldsets 716 20 701.494708ms +kotlin-compat-fragments_with_type_condition 709 17 671.426347ms +kotlin-operationBased-fragment_used_twice 701 18 753.996157ms +java-operationBased-named_fragment_without_implementation 681 6 102.807679ms +kotlin-operationBased-nested_field_with_multiple_fieldsets 677 16 588.836704ms +java-operationBased-fragment_with_multiple_fieldsets 675 7 128.127688ms +java-operationBased-hero_details_semantic_naming 675 6 104.740091ms +kotlin-responseBased-simple_fragment 674 15 497.307647ms +kotlin-operationBased-inline_fragment_merge_fields 667 23 596.896084ms +kotlin-responseBased-two_heroes_with_friends 661 14 523.340336ms +kotlin-operationBased-multiple_fragments 659 15 516.007660ms +java-operationBased-path_vs_flat_accessors 658 5 125.114260ms +kotlin-compat-simple_fragment_with_inline_fragments 639 15 562.634235ms +java-operationBased-reserved_keywords 635 7 91.649316ms +java-operationBased-typename_always_first 630 4 117.001928ms +kotlin-responseBased-inline_fragments_with_friends 626 13 662.635985ms +kotlin-operationBased-root_query_inline_fragment 623 18 521.353386ms +kotlin-operationBased-fragments_with_type_condition 621 12 543.916645ms +kotlin-operationBased-named_fragment_inside_inline_fragment 618 15 499.741071ms +kotlin-compat-nested_field_with_multiple_fieldsets 616 9 601.783128ms +kotlin-compat-named_fragment_inside_inline_fragment 613 11 547.277514ms +java-operationBased-interface_on_interface 610 5 95.172700ms +kotlin-compat-simple_fragment 610 13 523.690057ms +kotlin-compat-inline_fragments_with_friends 606 12 549.710715ms +java-operationBased-introspection_query 605 5 100.085271ms +kotlin-responseBased-deprecated_merged_field 602 26 902.946901ms +kotlin-responseBased-simple_union 601 12 498.494620ms +kotlin-responseBased-root_query_inline_fragment 595 10 662.259062ms +kotlin-compat-fragment_spread_with_nested_fields 594 24 651.651577ms +kotlin-responseBased-named_fragment_inside_inline_fragment 589 19 601.534330ms +java-operationBased-root_query_fragment 584 7 97.437048ms +kotlin-compat-fragment_spread_with_include_directive 583 13 677.082421ms +kotlin-operationBased-inline_fragments_with_friends 573 14 564.063665ms +java-operationBased-input_object_variable_and_argument 569 9 93.439003ms +java-operationBased-interface_always_nested 565 4 88.438125ms +kotlin-operationBased-simple_fragment_with_inline_fragments 565 16 698.376747ms +kotlin-compat-root_query_inline_fragment 563 20 595.879357ms +kotlin-operationBased-fragment_spread_with_nested_fields 554 16 700.490263ms +kotlin-responseBased-fragments_same_type_condition 553 12 492.020889ms +java-operationBased-deprecation 544 9 143.529581ms +kotlin-compat-simple_union 542 25 584.428380ms +kotlin-compat-inline_fragment_with_include_directive 540 8 491.185833ms +kotlin-operationBased-fragment_spread_with_include_directive 539 20 667.768648ms +java-operationBased-recursive_selection 538 3 85.095144ms +java-operationBased-hero_with_review 529 6 93.324606ms +kotlin-compat-union_fragment 529 12 648.922395ms +kotlin-compat-deprecated_merged_field 528 20 755.523179ms +kotlin-responseBased-test_inline 527 11 560.305507ms +kotlin-compat-not_all_combinations_are_needed 526 130 661.777623ms +kotlin-compat-fragments_same_type_condition 524 11 563.882368ms +kotlin-operationBased-simple_fragment 522 12 449.294138ms +kotlin-compat-inline_fragment_inside_inline_fragment 521 10 555.727405ms +kotlin-responseBased-fragment_with_multiple_fieldsets 512 18 514.382317ms +kotlin-compat-fieldset_with_multiple_super 511 14 680.885526ms +kotlin-responseBased-union_fragment 508 34 454.055758ms +java-operationBased-field_with_include_directive 507 8 109.703748ms +java-operationBased-hero_name_query_long_name 504 5 129.900381ms +java-operationBased-variable_default_value 504 4 81.773556ms +java-operationBased-hero_name 503 4 96.279764ms +kotlin-operationBased-simple_union 498 19 913.642899ms +kotlin-operationBased-inline_fragment_inside_inline_fragment 489 14 463.286078ms +kotlin-operationBased-inline_fragment_with_include_directive 489 10 547.207028ms +kotlin-responseBased-inline_fragment_merge_fields 488 13 550.744522ms +kotlin-responseBased-hero_details 487 20 513.474693ms +kotlin-compat-inline_fragment_merge_fields 486 9 476.885081ms +java-operationBased-custom_scalar_type 484 10 110.571808ms +kotlin-operationBased-fieldset_with_multiple_super 483 29 669.246999ms +kotlin-responseBased-inline_fragment_inside_inline_fragment 482 11 503.940751ms +kotlin-compat-named_fragment_without_implementation 481 16 494.513586ms +kotlin-operationBased-fragments_same_type_condition 480 13 451.377319ms +java-operationBased-optional 479 4 136.451688ms +kotlin-operationBased-simple_inline_fragment 478 13 558.245612ms +kotlin-operationBased-union_fragment 478 9 538.275417ms +kotlin-operationBased-not_all_combinations_are_needed 475 15 587.113688ms +kotlin-operationBased-deprecated_merged_field 472 26 811.105892ms +java-operationBased-inline_fragment_for_non_optional_field 471 4 94.211637ms +kotlin-responseBased-fieldset_with_multiple_super 470 11 719.058990ms +kotlin-responseBased-named_fragment_without_implementation 470 10 548.204025ms +kotlin-responseBased-simple_inline_fragment 468 10 1.059649046s +kotlin-compat-test_inline 468 8 558.306410ms +java-operationBased-inline_fragment_type_coercion 466 4 86.202106ms +java-operationBased-java8annotation 464 4 89.704809ms +java-operationBased-two_heroes_unique 459 5 76.057887ms +kotlin-compat-fragment_with_multiple_fieldsets 448 9 583.890393ms +kotlin-responseBased-not_all_combinations_are_needed 447 15 433.742408ms +kotlin-operationBased-test_inline 445 10 420.815384ms +kotlin-responseBased-reserved_keywords 444 9 425.078650ms +kotlin-compat-simple_inline_fragment 444 11 598.585378ms +kotlin-operationBased-named_fragment_without_implementation 437 10 457.970563ms +kotlin-responseBased-path_vs_flat_accessors 422 9 435.490710ms +kotlin-compat-reserved_keywords 421 7 462.810766ms +kotlin-operationBased-reserved_keywords 414 8 474.365160ms +java-operationBased-starships 411 5 129.632128ms +kotlin-responseBased-hero_details_semantic_naming 409 11 515.182219ms +kotlin-compat-path_vs_flat_accessors 405 7 494.856456ms +kotlin-responseBased-interface_on_interface 400 7 452.599298ms +java-operationBased-subscriptions 400 6 88.734898ms +kotlin-responseBased-typename_always_first 400 7 429.770091ms +kotlin-operationBased-fragment_with_multiple_fieldsets 398 14 421.960412ms +java-operationBased-antlr_tokens 397 20 141.292972ms +kotlin-operationBased-path_vs_flat_accessors 391 8 429.575523ms +kotlin-responseBased-root_query_fragment 388 10 379.172154ms +kotlin-responseBased-input_object_variable_and_argument 387 11 436.755234ms +kotlin-operationBased-typename_always_first 387 11 601.872027ms +kotlin-compat-typename_always_first 387 9 494.551903ms +kotlin-compat-root_query_fragment 386 7 478.140749ms +kotlin-compat-interface_on_interface 378 6 486.117238ms +kotlin-responseBased-hero_name 376 7 388.481767ms +java-operationBased-arguments_hardcoded 374 18 146.733746ms +kotlin-operationBased-interface_on_interface 371 7 414.663231ms +kotlin-responseBased-interface_always_nested 368 6 416.173241ms +kotlin-responseBased-hero_with_review 358 11 469.001554ms +java-operationBased-merged_include 354 3 96.130619ms +kotlin-compat-interface_always_nested 353 17 432.065955ms +java-operationBased-operation_id_generator 353 3 99.856828ms +kotlin-responseBased-deprecation 350 11 683.503774ms +kotlin-responseBased-hero_name_query_long_name 348 7 397.570649ms +kotlin-compat-hero_name 344 6 405.498516ms +kotlin-operationBased-root_query_fragment 342 7 450.042727ms +java-operationBased-case_sensitive_enum 341 7 115.421711ms +java-operationBased-enum_field 341 25 332.325059ms +java-operationBased-enums_as_sealed 341 4 118.929684ms +kotlin-responseBased-custom_scalar_type 339 17 747.887015ms +kotlin-operationBased-interface_always_nested 339 7 520.194391ms +java-operationBased-nonnull 335 5 121.584273ms +kotlin-responseBased-inline_fragment_for_non_optional_field 332 10 410.868465ms +kotlin-responseBased-introspection_query 332 16 419.816832ms +kotlin-responseBased-field_with_include_directive 318 16 538.693369ms +kotlin-responseBased-variable_default_value 317 7 379.854352ms +kotlin-operationBased-hero_name 316 8 463.559966ms +kotlin-responseBased-inline_fragment_type_coercion 314 9 386.945535ms +kotlin-compat-inline_fragment_for_non_optional_field 303 7 435.951386ms +kotlin-responseBased-recursive_selection 302 9 495.591808ms +kotlin-responseBased-optional 298 7 458.503757ms +kotlin-compat-inline_fragment_type_coercion 290 7 373.159470ms +kotlin-operationBased-inline_fragment_for_non_optional_field 286 8 376.971162ms +kotlin-operationBased-inline_fragment_type_coercion 276 6 402.222659ms +kotlin-responseBased-two_heroes_unique 273 7 319.355528ms +kotlin-responseBased-java8annotation 266 6 340.887875ms +kotlin-responseBased-starships 263 9 470.887314ms +kotlin-responseBased-antlr_tokens 256 65 808.324993ms +kotlin-responseBased-subscriptions 252 5 321.560791ms +kotlin-responseBased-arguments_hardcoded 245 19 694.925323ms +kotlin-responseBased-enums_as_sealed 225 19 477.999914ms +kotlin-responseBased-operation_id_generator 207 5 382.733335ms +kotlin-responseBased-merged_include 206 5 388.374971ms +kotlin-responseBased-nonnull 191 9 426.059226ms +kotlin-responseBased-case_sensitive_enum 190 8 579.551637ms +kotlin-responseBased-enum_field 189 8 738.728027ms +kotlin-responseBased-empty 0 0 234.355566ms +java-operationBased-empty 0 0 8.656us \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected index 443433d8ff1..ea705fbc9df 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected @@ -46,7 +46,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val while_: String, + public val `while`: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index d990629b32e..a5cae9caf68 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -63,19 +63,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Yield { - var while_: String? = null + var `while`: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Yield( - while_ = while_!!, + `while` = `while`!!, name = name!! ) } @@ -86,7 +86,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Yield ): Unit { writer.name("while") - StringAdapter.toJson(writer, customScalarAdapters, value.while_) + StringAdapter.toJson(writer, customScalarAdapters, value.`while`) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected index 825a14b2041..151bc60ec7a 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val while_: String, + public val `while`: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index 1473ffe8400..bf6070df1ad 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -62,19 +62,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var while_: String? = null + var `while`: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - while_ = while_!!, + `while` = `while`!!, name = name!! ) } @@ -85,7 +85,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data.Yield ): Unit { writer.name("while") - StringAdapter.toJson(writer, customScalarAdapters, value.while_) + StringAdapter.toJson(writer, customScalarAdapters, value.`while`) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected index 394e62e59bd..8fe1a28207c 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected @@ -45,7 +45,7 @@ public class TestQuery() : Query { /** * The ID of the character */ - public val while_: String, + public val `while`: String, /** * The name of the character */ diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index 48275d5b145..c95fb01c1dc 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -59,19 +59,19 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { - var while_: String? = null + var `while`: String? = null var name: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> while_ = StringAdapter.fromJson(reader, customScalarAdapters) + 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( - while_ = while_!!, + `while` = `while`!!, name = name!! ) } @@ -82,7 +82,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data.Yield ): Unit { writer.name("while") - StringAdapter.toJson(writer, customScalarAdapters, value.while_) + StringAdapter.toJson(writer, customScalarAdapters, value.`while`) writer.name("name") StringAdapter.toJson(writer, customScalarAdapters, value.name) From e3aeb455729db79ed8df904ace4097a25dc5bf0a Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 1 Dec 2021 12:55:36 +0100 Subject: [PATCH 4/7] Escape more cases, and add an integration test --- .../codegen/kotlin/helpers/NamedType.kt | 9 ++++---- .../selections/CompiledSelectionsBuilder.kt | 6 ++--- tests/escaping/build.gradle.kts | 14 +++++++++++ .../src/main/graphql/operation.graphql | 6 +++++ .../escaping/src/main/graphql/schema.graphqls | 15 ++++++++++++ .../src/test/kotlin/test/EscapingTest.kt | 23 +++++++++++++++++++ 6 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 tests/escaping/build.gradle.kts create mode 100644 tests/escaping/src/main/graphql/operation.graphql create mode 100644 tests/escaping/src/main/graphql/schema.graphqls create mode 100644 tests/escaping/src/test/kotlin/test/EscapingTest.kt diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/NamedType.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/NamedType.kt index 3a5a7f9b6a0..501448d9228 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/NamedType.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/helpers/NamedType.kt @@ -1,8 +1,8 @@ package com.apollographql.apollo3.compiler.codegen.kotlin.helpers import com.apollographql.apollo3.compiler.applyIf -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.Identifier +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.ir.IrInputField import com.apollographql.apollo3.compiler.ir.IrType @@ -61,12 +61,13 @@ internal fun NamedType.writeToResponseCodeBlock(context: KotlinContext): CodeBlo val propertyName = context.layout.propertyName(graphQlName) if (type.isOptional()) { - builder.beginControlFlow("if (${Identifier.value}.$propertyName is %T)", KotlinSymbols.Present) + builder.beginControlFlow("if (${Identifier.value}.%N is %T)", propertyName, KotlinSymbols.Present) } builder.addStatement("${Identifier.writer}.name(%S)", graphQlName) builder.addStatement( - "%L.${Identifier.toJson}(${Identifier.writer}, ${Identifier.customScalarAdapters}, ${Identifier.value}.$propertyName)", - adapterInitializer + "%L.${Identifier.toJson}(${Identifier.writer}, ${Identifier.customScalarAdapters}, ${Identifier.value}.%N)", + adapterInitializer, + propertyName, ) if (type.isOptional()) { builder.endControlFlow() diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/selections/CompiledSelectionsBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/selections/CompiledSelectionsBuilder.kt index 833cca49ac9..41ae4e9dfd9 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/selections/CompiledSelectionsBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/selections/CompiledSelectionsBuilder.kt @@ -30,8 +30,8 @@ import com.apollographql.apollo3.ast.definitionFromScope import com.apollographql.apollo3.ast.leafType import com.apollographql.apollo3.compiler.applyIf import com.apollographql.apollo3.compiler.capitalizeFirstLetter -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.ir.toBooleanExpression import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.KModifier @@ -154,7 +154,7 @@ class CompiledSelectionsBuilder( val selections = selectionSet?.selections ?: emptyList() if (selections.isNotEmpty()) { nestededPropertySpecs = selections.walk(alias ?: name, private, fieldDefinition.type.leafType().name) - builder.add(".selections(%L)\n", nestededPropertySpecs.last().name) + builder.add(".selections(%N)\n", nestededPropertySpecs.last().name) } builder.add(".build()") @@ -182,7 +182,7 @@ class CompiledSelectionsBuilder( if (selections.isNotEmpty()) { val name = "on${typeCondition.name.capitalizeFirstLetter()}" nestedPropertySpecs = selections.walk(name, private, typeCondition.name) - builder.add(".selections(%L)\n", nestedPropertySpecs.last().name) + builder.add(".selections(%N)\n", nestedPropertySpecs.last().name) } builder.add(".build()") diff --git a/tests/escaping/build.gradle.kts b/tests/escaping/build.gradle.kts new file mode 100644 index 00000000000..c8eb7ad5f10 --- /dev/null +++ b/tests/escaping/build.gradle.kts @@ -0,0 +1,14 @@ +plugins { + id("org.jetbrains.kotlin.jvm") + id("com.apollographql.apollo3") +} + +dependencies { + implementation("com.apollographql.apollo3:apollo-runtime") + testImplementation(groovy.util.Eval.x(project, "x.dep.kotlinJunit")) + testImplementation(groovy.util.Eval.x(project, "x.dep.junit")) +} + +apollo { + packageName.set("reserved") +} diff --git a/tests/escaping/src/main/graphql/operation.graphql b/tests/escaping/src/main/graphql/operation.graphql new file mode 100644 index 00000000000..702374d7437 --- /dev/null +++ b/tests/escaping/src/main/graphql/operation.graphql @@ -0,0 +1,6 @@ +query while($return: val, $for: do!) { + while(return: $return, for: $for) { + if + yield + } +} diff --git a/tests/escaping/src/main/graphql/schema.graphqls b/tests/escaping/src/main/graphql/schema.graphqls new file mode 100644 index 00000000000..e39de3dfbf6 --- /dev/null +++ b/tests/escaping/src/main/graphql/schema.graphqls @@ -0,0 +1,15 @@ +type Query { + while(return: val, for: do!): while +} + +type while { + if: ID + yield: val +} + +scalar val + +input do { + if: ID + yield: val +} diff --git a/tests/escaping/src/test/kotlin/test/EscapingTest.kt b/tests/escaping/src/test/kotlin/test/EscapingTest.kt new file mode 100644 index 00000000000..ee0e51177a1 --- /dev/null +++ b/tests/escaping/src/test/kotlin/test/EscapingTest.kt @@ -0,0 +1,23 @@ +package test + +import com.apollographql.apollo3.ApolloClient +import com.apollographql.apollo3.api.Optional +import reserved.WhileQuery +import reserved.type.Do + +class EscapingTest { + // Not actually a test, we're just making sure this compiles + suspend fun test() { + val response = ApolloClient.Builder().build() + .query(WhileQuery( + `return` = "public", + `for` = Do( + `if` = Optional.Absent, + yield_ = Optional.Absent, + ), + )) + .execute() + val `while`: WhileQuery.While? = response.dataAssertNoErrors.`while` + val `if`: String? = `while`?.`if` + } +} From fdffe2d57fd139fb28b5b47e203ce7c418c4f93a Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 1 Dec 2021 13:14:13 +0100 Subject: [PATCH 5/7] Keep `it` in one of the tests --- .../reserved_keywords/TestOperation.graphql | 2 +- .../reserved_keywords/TestQuery.java.expected | 18 +++++++++--------- .../TestQuery_ResponseAdapter.java.expected | 14 +++++++------- .../TestQuerySelections.java.expected | 2 +- .../reserved_keywords/TestQuery.kt.expected | 8 ++++---- .../TestQuery_ResponseAdapter.kt.expected | 12 ++++++------ .../selections/TestQuerySelections.kt.expected | 3 ++- .../reserved_keywords/TestQuery.kt.expected | 8 ++++---- .../TestQuery_ResponseAdapter.kt.expected | 12 ++++++------ .../selections/TestQuerySelections.kt.expected | 3 ++- .../reserved_keywords/TestQuery.kt.expected | 8 ++++---- .../TestQuery_ResponseAdapter.kt.expected | 12 ++++++------ .../selections/TestQuerySelections.kt.expected | 3 ++- 13 files changed, 54 insertions(+), 51 deletions(-) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql index 2cd21570c4a..bb690d27491 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql @@ -1,7 +1,7 @@ query TestQuery { yield: hero { while: id - name + it: name } objects: search(text: "abc") { diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected index 7ec5e049fe3..fae463a4685 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/TestQuery.java.expected @@ -19,7 +19,7 @@ import java.lang.String; import java.util.List; public class TestQuery implements Query { - public static final String OPERATION_ID = "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5"; + public static final String OPERATION_ID = "d2f555fdc0bd9ea0a928c39aa7818ac66b0c0a0870772b1fb57387c3c3cf8577"; /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -28,7 +28,7 @@ public class TestQuery implements Query { * query TestQuery { * yield: hero { * while: id - * name + * it: name * } * objects: search(text: "abc") { * __typename @@ -37,7 +37,7 @@ public class TestQuery implements Query { * } * } * } */ - public static final String OPERATION_DOCUMENT = "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }"; + public static final String OPERATION_DOCUMENT = "query TestQuery { yield: hero { while: id it: name } objects: search(text: \"abc\") { __typename ... on Character { name } } }"; public static final String OPERATION_NAME = "TestQuery"; @@ -176,7 +176,7 @@ public class TestQuery implements Query { /** * The name of the character */ - public String name; + public String it; private transient volatile int $hashCode; @@ -184,9 +184,9 @@ public class TestQuery implements Query { private transient volatile String $toString; - public Yield(String while_, String name) { + public Yield(String while_, String it) { this.while_ = while_; - this.name = name; + this.it = it; } @Override @@ -197,7 +197,7 @@ public class TestQuery implements Query { if (o instanceof Yield) { Yield that = (Yield) o; return ((this.while_ == null) ? (that.while_ == null) : this.while_.equals(that.while_)) - &&((this.name == null) ? (that.name == null) : this.name.equals(that.name)); + &&((this.it == null) ? (that.it == null) : this.it.equals(that.it)); } return false; } @@ -209,7 +209,7 @@ public class TestQuery implements Query { h *= 1000003; h ^= (while_ == null) ? 0 : while_.hashCode(); h *= 1000003; - h ^= (name == null) ? 0 : name.hashCode(); + h ^= (it == null) ? 0 : it.hashCode(); $hashCode = h; $hashCodeMemoized = true; } @@ -221,7 +221,7 @@ public class TestQuery implements Query { if ($toString == null) { $toString = "Yield{" + "while_=" + while_ + ", " - + "name=" + name + + "it=" + it + "}"; } return $toString; diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected index 2bb87b4f116..5cd36c0d44f 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.java.expected @@ -67,29 +67,29 @@ public class TestQuery_ResponseAdapter { public enum Yield implements Adapter { INSTANCE; - private static final List RESPONSE_NAMES = Arrays.asList("while", "name"); + private static final List RESPONSE_NAMES = Arrays.asList("while", "it"); @Override public TestQuery.Yield fromJson(JsonReader reader, CustomScalarAdapters customScalarAdapters) throws IOException { String while_ = null; - String name = null; + String it = null; loop: while(true) { switch (reader.selectName(RESPONSE_NAMES)) { case 0: while_ = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; - case 1: name = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; + case 1: it = Adapters.StringAdapter.fromJson(reader, customScalarAdapters); break; default: break loop; } } Assertions.checkFieldNotMissing(while_, "while"); - Assertions.checkFieldNotMissing(name, "name"); + Assertions.checkFieldNotMissing(it, "it"); return new TestQuery.Yield( while_, - name + it ); } @@ -99,8 +99,8 @@ public class TestQuery_ResponseAdapter { writer.name("while"); Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.while_); - writer.name("name"); - Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.name); + writer.name("it"); + Adapters.StringAdapter.toJson(writer, customScalarAdapters, value.it); } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected index 6d59d39e8e1..0345ffc0ff6 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/java/operationBased/reserved_keywords/selections/TestQuerySelections.java.expected @@ -20,7 +20,7 @@ import java.util.List; public class TestQuerySelections { private static List yield = Arrays.asList( new CompiledField.Builder("id", new CompiledNotNullType(CompiledGraphQL.CompiledIDType)).alias("while").build(), - new CompiledField.Builder("name", new CompiledNotNullType(CompiledGraphQL.CompiledStringType)).build() + new CompiledField.Builder("name", new CompiledNotNullType(CompiledGraphQL.CompiledStringType)).alias("it").build() ); private static List onCharacter = Arrays.asList( diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected index ea705fbc9df..7b57b810294 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected @@ -50,7 +50,7 @@ public class TestQuery() : Query { /** * The name of the character */ - public val name: String + public val it: String ) public data class Object( @@ -71,7 +71,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" + "d2f555fdc0bd9ea0a928c39aa7818ac66b0c0a0870772b1fb57387c3c3cf8577" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -80,7 +80,7 @@ public class TestQuery() : Query { * query TestQuery { * yield: hero { * while: id - * name + * it: name * } * objects: search(text: "abc") { * __typename @@ -91,7 +91,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id it: name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index a5cae9caf68..c57f91bd1de 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -59,24 +59,24 @@ public object TestQuery_ResponseAdapter { } public object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("while", "name") + public val RESPONSE_NAMES: List = listOf("while", "it") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Yield { var `while`: String? = null - var name: String? = null + var it: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) - 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) + 1 -> it = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Yield( `while` = `while`!!, - name = name!! + it = it!! ) } @@ -88,8 +88,8 @@ public object TestQuery_ResponseAdapter { writer.name("while") StringAdapter.toJson(writer, customScalarAdapters, value.`while`) - writer.name("name") - StringAdapter.toJson(writer, customScalarAdapters, value.name) + writer.name("it") + StringAdapter.toJson(writer, customScalarAdapters, value.it) } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected index 3e90903bda0..72bb5f5aab1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -27,7 +27,8 @@ public object TestQuerySelections { CompiledField.Builder( name = "name", type = CompiledStringType.notNull() - ).build() + ).alias("it") + .build() ) private val onCharacter: List = listOf( diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected index 151bc60ec7a..76fd4718e99 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected @@ -49,7 +49,7 @@ public class TestQuery() : Query { /** * The name of the character */ - public val name: String + public val it: String ) public data class Object( @@ -70,7 +70,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" + "d2f555fdc0bd9ea0a928c39aa7818ac66b0c0a0870772b1fb57387c3c3cf8577" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -79,7 +79,7 @@ public class TestQuery() : Query { * query TestQuery { * yield: hero { * while: id - * name + * it: name * } * objects: search(text: "abc") { * __typename @@ -90,7 +90,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id it: name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index bf6070df1ad..bb1719c120d 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -58,24 +58,24 @@ public object TestQuery_ResponseAdapter { } private object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("while", "name") + public val RESPONSE_NAMES: List = listOf("while", "it") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { var `while`: String? = null - var name: String? = null + var it: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) - 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) + 1 -> it = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( `while` = `while`!!, - name = name!! + it = it!! ) } @@ -87,8 +87,8 @@ public object TestQuery_ResponseAdapter { writer.name("while") StringAdapter.toJson(writer, customScalarAdapters, value.`while`) - writer.name("name") - StringAdapter.toJson(writer, customScalarAdapters, value.name) + writer.name("it") + StringAdapter.toJson(writer, customScalarAdapters, value.it) } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 3e90903bda0..72bb5f5aab1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -27,7 +27,8 @@ public object TestQuerySelections { CompiledField.Builder( name = "name", type = CompiledStringType.notNull() - ).build() + ).alias("it") + .build() ) private val onCharacter: List = listOf( diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected index 8fe1a28207c..5c285c4c17b 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected @@ -49,7 +49,7 @@ public class TestQuery() : Query { /** * The name of the character */ - public val name: String + public val it: String ) public sealed interface Object { @@ -75,7 +75,7 @@ public class TestQuery() : Query { public companion object { public const val OPERATION_ID: String = - "6a337ab7c3e44de1799c5128f5722cffb334fb9f29f261f6d304231a98aadbd5" + "d2f555fdc0bd9ea0a928c39aa7818ac66b0c0a0870772b1fb57387c3c3cf8577" /** * The minimized GraphQL document being sent to the server to save a few bytes. @@ -84,7 +84,7 @@ public class TestQuery() : Query { * query TestQuery { * yield: hero { * while: id - * name + * it: name * } * objects: search(text: "abc") { * __typename @@ -95,7 +95,7 @@ public class TestQuery() : Query { * } */ public const val OPERATION_DOCUMENT: String = - "query TestQuery { yield: hero { while: id name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" + "query TestQuery { yield: hero { while: id it: name } objects: search(text: \"abc\") { __typename ... on Character { name } } }" public const val OPERATION_NAME: String = "TestQuery" } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index c95fb01c1dc..d23b64689cd 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -55,24 +55,24 @@ public object TestQuery_ResponseAdapter { } private object Yield : Adapter { - public val RESPONSE_NAMES: List = listOf("while", "name") + public val RESPONSE_NAMES: List = listOf("while", "it") public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data.Yield { var `while`: String? = null - var name: String? = null + var it: String? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { 0 -> `while` = StringAdapter.fromJson(reader, customScalarAdapters) - 1 -> name = StringAdapter.fromJson(reader, customScalarAdapters) + 1 -> it = StringAdapter.fromJson(reader, customScalarAdapters) else -> break } } return TestQuery.Data.Yield( `while` = `while`!!, - name = name!! + it = it!! ) } @@ -84,8 +84,8 @@ public object TestQuery_ResponseAdapter { writer.name("while") StringAdapter.toJson(writer, customScalarAdapters, value.`while`) - writer.name("name") - StringAdapter.toJson(writer, customScalarAdapters, value.name) + writer.name("it") + StringAdapter.toJson(writer, customScalarAdapters, value.it) } } diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 3e90903bda0..72bb5f5aab1 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -27,7 +27,8 @@ public object TestQuerySelections { CompiledField.Builder( name = "name", type = CompiledStringType.notNull() - ).build() + ).alias("it") + .build() ) private val onCharacter: List = listOf( From 3323c10bda99713d8812ca39e244777f14179a18 Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 1 Dec 2021 16:56:54 +0100 Subject: [PATCH 6/7] Escape yield with `yield` instead of `yield_` --- .../apollo3/compiler/ReservedKeywords.kt | 4 +- .../src/test/graphql/com/example/measurements | 460 +++++++++--------- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuerySelections.kt.expected | 4 +- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuerySelections.kt.expected | 4 +- .../reserved_keywords/TestQuery.kt.expected | 2 +- .../TestQuery_ResponseAdapter.kt.expected | 8 +- .../TestQuerySelections.kt.expected | 4 +- gradle/dependencies.gradle | 2 +- .../src/test/kotlin/test/EscapingTest.kt | 2 +- 13 files changed, 255 insertions(+), 255 deletions(-) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt index 73cf28691e8..e5fa7eede2c 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ReservedKeywords.kt @@ -10,7 +10,7 @@ private val JAVA_RESERVED_WORDS = arrayOf( "transient", "try", "true", "void", "volatile", "while" ) -// Note: reserved keywords escaping is handled by KotlinPoet, but "yield" is actually missing from its list, +// Note: reserved keywords escaping is handled by KotlinPoet, but "yield" is missing from its list at the moment // so we handle it ourselves (see https://github.com/apollographql/apollo-android/issues/1957) private val KOTLIN_RESERVED_WORDS = arrayOf("yield") @@ -20,6 +20,6 @@ private val KOTLIN_RESERVED_ENUM_VALUE_NAMES = arrayOf("name", "ordinal") fun String.escapeJavaReservedWord() = if (this in JAVA_RESERVED_WORDS) "${this}_" else this -fun String.escapeKotlinReservedWord() = if (this in KOTLIN_RESERVED_WORDS) "${this}_" else this +fun String.escapeKotlinReservedWord() = if (this in KOTLIN_RESERVED_WORDS) "`${this}`" else this fun String.escapeKotlinReservedEnumValueNames() = if (this in (KOTLIN_RESERVED_WORDS + KOTLIN_RESERVED_ENUM_VALUE_NAMES)) "${this}_" else this diff --git a/apollo-compiler/src/test/graphql/com/example/measurements b/apollo-compiler/src/test/graphql/com/example/measurements index 464556f8c96..3e5a3cc49ef 100644 --- a/apollo-compiler/src/test/graphql/com/example/measurements +++ b/apollo-compiler/src/test/graphql/com/example/measurements @@ -1,232 +1,232 @@ Test: Total LOC: Codegen (ms): Compilation (ms): -aggregate all 146069 3.527270560s 1m 47.394797915s -aggregate responseBased 39008 1.394195753s 46.762166169s -aggregate operationBased 81192 1.402876125s 34.636349629s -aggregate compat 25869 730.198682ms 25.996282117s +aggregate all 146072 3.538892837s 1m 48.105408653s +aggregate responseBased 39009 1.298149115s 47.163356331s +aggregate operationBased 81193 1.463040379s 35.667390617s +aggregate compat 25870 777.703343ms 25.274661705s -kotlin-responseBased-fragment_with_inline_fragment 2188 79 1.514746331s -java-operationBased-nested_named_fragments 1739 16 238.624710ms -java-operationBased-fragment_with_inline_fragment 1703 17 154.943475ms -java-operationBased-union_inline_fragments 1523 9 139.652433ms -java-operationBased-inline_fragment_intersection 1499 15 159.305914ms -java-operationBased-unique_type_name 1497 11 136.039757ms -java-operationBased-root_query_fragment_with_nested_fragments 1437 10 132.768144ms -kotlin-responseBased-nested_named_fragments 1435 38 1.098481838s -java-operationBased-mutation_create_review 1351 9 146.244882ms -kotlin-compat-fragment_with_inline_fragment 1323 29 1.127864566s -java-operationBased-__schema 1314 78 823.799153ms -java-operationBased-named_fragment_delegate 1312 8 136.387006ms -java-operationBased-named_fragment_with_variables 1223 22 157.735470ms -kotlin-compat-nested_named_fragments 1203 23 972.748373ms -kotlin-responseBased-unique_type_name 1185 29 799.324778ms -java-operationBased-nested_conditional_inline 1181 20 145.762985ms -kotlin-responseBased-named_fragment_delegate 1166 44 818.908907ms -java-operationBased-input_object_type 1162 8 129.160314ms -java-operationBased-nested_field_with_multiple_fieldsets 1152 13 149.195101ms -java-operationBased-mutation_create_review_semantic_naming 1147 9 151.024526ms -java-operationBased-fragment_used_twice 1144 11 143.723288ms -java-operationBased-multiple_fragments 1129 10 144.698615ms -java-operationBased-two_heroes_with_friends 1103 13 179.474956ms -java-operationBased-inline_fragment_merge_fields 1102 10 126.375186ms -kotlin-operationBased-nested_named_fragments 1079 28 883.718647ms -kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 25 650.895769ms -kotlin-responseBased-inline_fragment_intersection 1073 28 849.069583ms -kotlin-operationBased-fragment_with_inline_fragment 1051 24 947.435012ms -kotlin-compat-inline_fragment_intersection 1040 16 950.141948ms -java-operationBased-named_fragment_inside_inline_fragment 1037 8 118.707293ms -java-operationBased-fragments_with_type_condition 1003 8 105.244390ms -kotlin-compat-unique_type_name 994 17 797.182552ms -java-operationBased-root_query_inline_fragment 982 13 130.264701ms -kotlin-operationBased-inline_fragment_intersection 976 35 783.102790ms -kotlin-operationBased-union_inline_fragments 974 21 827.762393ms -kotlin-responseBased-union_inline_fragments 971 21 677.823693ms -kotlin-responseBased-__schema 969 196 5.953447004s -kotlin-compat-root_query_fragment_with_nested_fragments 965 17 692.050409ms -kotlin-responseBased-fragment_used_twice 952 27 860.730175ms -kotlin-operationBased-unique_type_name 938 23 697.659935ms -java-operationBased-simple_fragment_with_inline_fragments 931 8 129.796120ms -kotlin-compat-union_inline_fragments 928 17 705.461449ms -java-operationBased-inline_fragments_with_friends 923 6 139.220986ms -java-operationBased-fragment_spread_with_nested_fields 916 11 160.557340ms -kotlin-responseBased-mutation_create_review 899 17 781.535101ms -kotlin-responseBased-simple_fragment_with_inline_fragments 896 22 571.165299ms -kotlin-responseBased-fragments_with_type_condition 894 21 666.926452ms -kotlin-responseBased-nested_conditional_inline 892 20 870.632830ms -java-operationBased-fragment_spread_with_include_directive 888 10 137.212097ms -kotlin-responseBased-named_fragment_with_variables 879 48 1.061199224s -kotlin-operationBased-root_query_fragment_with_nested_fragments 876 17 645.425334ms -kotlin-responseBased-multiple_fragments 875 27 662.494257ms -java-operationBased-simple_fragment 865 7 112.543165ms -kotlin-compat-named_fragment_delegate 840 22 592.785070ms -kotlin-compat-fragment_used_twice 835 19 730.216170ms -java-operationBased-simple_union 834 9 119.709775ms -kotlin-compat-named_fragment_with_variables 833 25 994.687814ms -java-operationBased-fragments_same_type_condition 814 8 125.504164ms -kotlin-compat-nested_conditional_inline 812 16 779.452237ms -java-operationBased-hero_details 810 6 112.422164ms -java-operationBased-deprecated_merged_field 803 14 138.063929ms -kotlin-operationBased-named_fragment_delegate 803 27 666.124884ms -java-operationBased-fieldset_with_multiple_super 797 8 115.521405ms -java-operationBased-not_all_combinations_are_needed 795 6 108.952674ms -java-operationBased-simple_inline_fragment 792 12 197.068974ms -java-operationBased-inline_fragment_with_include_directive 784 5 108.904721ms -java-operationBased-test_inline 761 6 102.865165ms -kotlin-responseBased-input_object_type 755 22 680.491098ms -java-operationBased-union_fragment 752 7 120.423961ms -java-operationBased-inline_fragment_inside_inline_fragment 749 8 108.493670ms -kotlin-compat-multiple_fragments 748 16 554.890182ms -kotlin-operationBased-named_fragment_with_variables 746 24 815.454782ms -kotlin-operationBased-nested_conditional_inline 746 17 641.347540ms -kotlin-responseBased-mutation_create_review_semantic_naming 741 14 673.407031ms -kotlin-responseBased-fragment_spread_with_nested_fields 723 30 720.609330ms -kotlin-responseBased-nested_field_with_multiple_fieldsets 716 20 701.494708ms -kotlin-compat-fragments_with_type_condition 709 17 671.426347ms -kotlin-operationBased-fragment_used_twice 701 18 753.996157ms -java-operationBased-named_fragment_without_implementation 681 6 102.807679ms -kotlin-operationBased-nested_field_with_multiple_fieldsets 677 16 588.836704ms -java-operationBased-fragment_with_multiple_fieldsets 675 7 128.127688ms -java-operationBased-hero_details_semantic_naming 675 6 104.740091ms -kotlin-responseBased-simple_fragment 674 15 497.307647ms -kotlin-operationBased-inline_fragment_merge_fields 667 23 596.896084ms -kotlin-responseBased-two_heroes_with_friends 661 14 523.340336ms -kotlin-operationBased-multiple_fragments 659 15 516.007660ms -java-operationBased-path_vs_flat_accessors 658 5 125.114260ms -kotlin-compat-simple_fragment_with_inline_fragments 639 15 562.634235ms -java-operationBased-reserved_keywords 635 7 91.649316ms -java-operationBased-typename_always_first 630 4 117.001928ms -kotlin-responseBased-inline_fragments_with_friends 626 13 662.635985ms -kotlin-operationBased-root_query_inline_fragment 623 18 521.353386ms -kotlin-operationBased-fragments_with_type_condition 621 12 543.916645ms -kotlin-operationBased-named_fragment_inside_inline_fragment 618 15 499.741071ms -kotlin-compat-nested_field_with_multiple_fieldsets 616 9 601.783128ms -kotlin-compat-named_fragment_inside_inline_fragment 613 11 547.277514ms -java-operationBased-interface_on_interface 610 5 95.172700ms -kotlin-compat-simple_fragment 610 13 523.690057ms -kotlin-compat-inline_fragments_with_friends 606 12 549.710715ms -java-operationBased-introspection_query 605 5 100.085271ms -kotlin-responseBased-deprecated_merged_field 602 26 902.946901ms -kotlin-responseBased-simple_union 601 12 498.494620ms -kotlin-responseBased-root_query_inline_fragment 595 10 662.259062ms -kotlin-compat-fragment_spread_with_nested_fields 594 24 651.651577ms -kotlin-responseBased-named_fragment_inside_inline_fragment 589 19 601.534330ms -java-operationBased-root_query_fragment 584 7 97.437048ms -kotlin-compat-fragment_spread_with_include_directive 583 13 677.082421ms -kotlin-operationBased-inline_fragments_with_friends 573 14 564.063665ms -java-operationBased-input_object_variable_and_argument 569 9 93.439003ms -java-operationBased-interface_always_nested 565 4 88.438125ms -kotlin-operationBased-simple_fragment_with_inline_fragments 565 16 698.376747ms -kotlin-compat-root_query_inline_fragment 563 20 595.879357ms -kotlin-operationBased-fragment_spread_with_nested_fields 554 16 700.490263ms -kotlin-responseBased-fragments_same_type_condition 553 12 492.020889ms -java-operationBased-deprecation 544 9 143.529581ms -kotlin-compat-simple_union 542 25 584.428380ms -kotlin-compat-inline_fragment_with_include_directive 540 8 491.185833ms -kotlin-operationBased-fragment_spread_with_include_directive 539 20 667.768648ms -java-operationBased-recursive_selection 538 3 85.095144ms -java-operationBased-hero_with_review 529 6 93.324606ms -kotlin-compat-union_fragment 529 12 648.922395ms -kotlin-compat-deprecated_merged_field 528 20 755.523179ms -kotlin-responseBased-test_inline 527 11 560.305507ms -kotlin-compat-not_all_combinations_are_needed 526 130 661.777623ms -kotlin-compat-fragments_same_type_condition 524 11 563.882368ms -kotlin-operationBased-simple_fragment 522 12 449.294138ms -kotlin-compat-inline_fragment_inside_inline_fragment 521 10 555.727405ms -kotlin-responseBased-fragment_with_multiple_fieldsets 512 18 514.382317ms -kotlin-compat-fieldset_with_multiple_super 511 14 680.885526ms -kotlin-responseBased-union_fragment 508 34 454.055758ms -java-operationBased-field_with_include_directive 507 8 109.703748ms -java-operationBased-hero_name_query_long_name 504 5 129.900381ms -java-operationBased-variable_default_value 504 4 81.773556ms -java-operationBased-hero_name 503 4 96.279764ms -kotlin-operationBased-simple_union 498 19 913.642899ms -kotlin-operationBased-inline_fragment_inside_inline_fragment 489 14 463.286078ms -kotlin-operationBased-inline_fragment_with_include_directive 489 10 547.207028ms -kotlin-responseBased-inline_fragment_merge_fields 488 13 550.744522ms -kotlin-responseBased-hero_details 487 20 513.474693ms -kotlin-compat-inline_fragment_merge_fields 486 9 476.885081ms -java-operationBased-custom_scalar_type 484 10 110.571808ms -kotlin-operationBased-fieldset_with_multiple_super 483 29 669.246999ms -kotlin-responseBased-inline_fragment_inside_inline_fragment 482 11 503.940751ms -kotlin-compat-named_fragment_without_implementation 481 16 494.513586ms -kotlin-operationBased-fragments_same_type_condition 480 13 451.377319ms -java-operationBased-optional 479 4 136.451688ms -kotlin-operationBased-simple_inline_fragment 478 13 558.245612ms -kotlin-operationBased-union_fragment 478 9 538.275417ms -kotlin-operationBased-not_all_combinations_are_needed 475 15 587.113688ms -kotlin-operationBased-deprecated_merged_field 472 26 811.105892ms -java-operationBased-inline_fragment_for_non_optional_field 471 4 94.211637ms -kotlin-responseBased-fieldset_with_multiple_super 470 11 719.058990ms -kotlin-responseBased-named_fragment_without_implementation 470 10 548.204025ms -kotlin-responseBased-simple_inline_fragment 468 10 1.059649046s -kotlin-compat-test_inline 468 8 558.306410ms -java-operationBased-inline_fragment_type_coercion 466 4 86.202106ms -java-operationBased-java8annotation 464 4 89.704809ms -java-operationBased-two_heroes_unique 459 5 76.057887ms -kotlin-compat-fragment_with_multiple_fieldsets 448 9 583.890393ms -kotlin-responseBased-not_all_combinations_are_needed 447 15 433.742408ms -kotlin-operationBased-test_inline 445 10 420.815384ms -kotlin-responseBased-reserved_keywords 444 9 425.078650ms -kotlin-compat-simple_inline_fragment 444 11 598.585378ms -kotlin-operationBased-named_fragment_without_implementation 437 10 457.970563ms -kotlin-responseBased-path_vs_flat_accessors 422 9 435.490710ms -kotlin-compat-reserved_keywords 421 7 462.810766ms -kotlin-operationBased-reserved_keywords 414 8 474.365160ms -java-operationBased-starships 411 5 129.632128ms -kotlin-responseBased-hero_details_semantic_naming 409 11 515.182219ms -kotlin-compat-path_vs_flat_accessors 405 7 494.856456ms -kotlin-responseBased-interface_on_interface 400 7 452.599298ms -java-operationBased-subscriptions 400 6 88.734898ms -kotlin-responseBased-typename_always_first 400 7 429.770091ms -kotlin-operationBased-fragment_with_multiple_fieldsets 398 14 421.960412ms -java-operationBased-antlr_tokens 397 20 141.292972ms -kotlin-operationBased-path_vs_flat_accessors 391 8 429.575523ms -kotlin-responseBased-root_query_fragment 388 10 379.172154ms -kotlin-responseBased-input_object_variable_and_argument 387 11 436.755234ms -kotlin-operationBased-typename_always_first 387 11 601.872027ms -kotlin-compat-typename_always_first 387 9 494.551903ms -kotlin-compat-root_query_fragment 386 7 478.140749ms -kotlin-compat-interface_on_interface 378 6 486.117238ms -kotlin-responseBased-hero_name 376 7 388.481767ms -java-operationBased-arguments_hardcoded 374 18 146.733746ms -kotlin-operationBased-interface_on_interface 371 7 414.663231ms -kotlin-responseBased-interface_always_nested 368 6 416.173241ms -kotlin-responseBased-hero_with_review 358 11 469.001554ms -java-operationBased-merged_include 354 3 96.130619ms -kotlin-compat-interface_always_nested 353 17 432.065955ms -java-operationBased-operation_id_generator 353 3 99.856828ms -kotlin-responseBased-deprecation 350 11 683.503774ms -kotlin-responseBased-hero_name_query_long_name 348 7 397.570649ms -kotlin-compat-hero_name 344 6 405.498516ms -kotlin-operationBased-root_query_fragment 342 7 450.042727ms -java-operationBased-case_sensitive_enum 341 7 115.421711ms -java-operationBased-enum_field 341 25 332.325059ms -java-operationBased-enums_as_sealed 341 4 118.929684ms -kotlin-responseBased-custom_scalar_type 339 17 747.887015ms -kotlin-operationBased-interface_always_nested 339 7 520.194391ms -java-operationBased-nonnull 335 5 121.584273ms -kotlin-responseBased-inline_fragment_for_non_optional_field 332 10 410.868465ms -kotlin-responseBased-introspection_query 332 16 419.816832ms -kotlin-responseBased-field_with_include_directive 318 16 538.693369ms -kotlin-responseBased-variable_default_value 317 7 379.854352ms -kotlin-operationBased-hero_name 316 8 463.559966ms -kotlin-responseBased-inline_fragment_type_coercion 314 9 386.945535ms -kotlin-compat-inline_fragment_for_non_optional_field 303 7 435.951386ms -kotlin-responseBased-recursive_selection 302 9 495.591808ms -kotlin-responseBased-optional 298 7 458.503757ms -kotlin-compat-inline_fragment_type_coercion 290 7 373.159470ms -kotlin-operationBased-inline_fragment_for_non_optional_field 286 8 376.971162ms -kotlin-operationBased-inline_fragment_type_coercion 276 6 402.222659ms -kotlin-responseBased-two_heroes_unique 273 7 319.355528ms -kotlin-responseBased-java8annotation 266 6 340.887875ms -kotlin-responseBased-starships 263 9 470.887314ms -kotlin-responseBased-antlr_tokens 256 65 808.324993ms -kotlin-responseBased-subscriptions 252 5 321.560791ms -kotlin-responseBased-arguments_hardcoded 245 19 694.925323ms -kotlin-responseBased-enums_as_sealed 225 19 477.999914ms -kotlin-responseBased-operation_id_generator 207 5 382.733335ms -kotlin-responseBased-merged_include 206 5 388.374971ms -kotlin-responseBased-nonnull 191 9 426.059226ms -kotlin-responseBased-case_sensitive_enum 190 8 579.551637ms -kotlin-responseBased-enum_field 189 8 738.728027ms -kotlin-responseBased-empty 0 0 234.355566ms -java-operationBased-empty 0 0 8.656us \ No newline at end of file +kotlin-responseBased-fragment_with_inline_fragment 2188 65 1.641401831s +java-operationBased-nested_named_fragments 1739 17 192.578168ms +java-operationBased-fragment_with_inline_fragment 1703 21 167.187065ms +java-operationBased-union_inline_fragments 1523 17 121.178005ms +java-operationBased-inline_fragment_intersection 1499 24 139.937675ms +java-operationBased-unique_type_name 1497 9 123.651520ms +java-operationBased-root_query_fragment_with_nested_fragments 1437 14 156.371672ms +kotlin-responseBased-nested_named_fragments 1435 45 824.131075ms +java-operationBased-mutation_create_review 1351 9 146.771351ms +kotlin-compat-fragment_with_inline_fragment 1323 52 1.146654339s +java-operationBased-__schema 1314 71 922.258201ms +java-operationBased-named_fragment_delegate 1312 12 141.705064ms +java-operationBased-named_fragment_with_variables 1223 17 168.613490ms +kotlin-compat-nested_named_fragments 1203 30 786.731583ms +kotlin-responseBased-unique_type_name 1185 26 732.682095ms +java-operationBased-nested_conditional_inline 1181 13 120.405190ms +kotlin-responseBased-named_fragment_delegate 1166 29 811.097210ms +java-operationBased-input_object_type 1162 16 167.012802ms +java-operationBased-nested_field_with_multiple_fieldsets 1152 8 103.234924ms +java-operationBased-mutation_create_review_semantic_naming 1147 11 113.459976ms +java-operationBased-fragment_used_twice 1144 15 152.038485ms +java-operationBased-multiple_fragments 1129 9 122.853654ms +java-operationBased-two_heroes_with_friends 1103 6 116.583641ms +java-operationBased-inline_fragment_merge_fields 1102 7 106.237061ms +kotlin-operationBased-nested_named_fragments 1079 20 664.015775ms +kotlin-responseBased-root_query_fragment_with_nested_fragments 1074 27 613.194518ms +kotlin-responseBased-inline_fragment_intersection 1073 22 927.288875ms +kotlin-operationBased-fragment_with_inline_fragment 1051 27 1.010026025s +kotlin-compat-inline_fragment_intersection 1040 42 1.058209389s +java-operationBased-named_fragment_inside_inline_fragment 1037 8 131.508750ms +java-operationBased-fragments_with_type_condition 1003 8 108.083917ms +kotlin-compat-unique_type_name 994 19 569.516127ms +java-operationBased-root_query_inline_fragment 982 7 114.121443ms +kotlin-operationBased-inline_fragment_intersection 976 20 1.250954628s +kotlin-operationBased-union_inline_fragments 974 22 641.835988ms +kotlin-responseBased-union_inline_fragments 971 30 764.569195ms +kotlin-responseBased-__schema 969 196 6.111833447s +kotlin-compat-root_query_fragment_with_nested_fragments 965 28 706.924199ms +kotlin-responseBased-fragment_used_twice 952 27 911.356607ms +kotlin-operationBased-unique_type_name 938 18 672.389214ms +java-operationBased-simple_fragment_with_inline_fragments 931 12 115.221944ms +kotlin-compat-union_inline_fragments 928 24 632.131180ms +java-operationBased-inline_fragments_with_friends 923 6 127.858143ms +java-operationBased-fragment_spread_with_nested_fields 916 9 168.970887ms +kotlin-responseBased-mutation_create_review 899 19 787.782407ms +kotlin-responseBased-simple_fragment_with_inline_fragments 896 22 636.480846ms +kotlin-responseBased-fragments_with_type_condition 894 18 730.336069ms +kotlin-responseBased-nested_conditional_inline 892 20 703.953980ms +java-operationBased-fragment_spread_with_include_directive 888 10 191.611036ms +kotlin-responseBased-named_fragment_with_variables 879 24 777.376839ms +kotlin-operationBased-root_query_fragment_with_nested_fragments 876 17 538.100438ms +kotlin-responseBased-multiple_fragments 875 16 581.723784ms +java-operationBased-simple_fragment 865 6 98.479872ms +kotlin-compat-named_fragment_delegate 840 77 681.266511ms +kotlin-compat-fragment_used_twice 835 23 739.964300ms +java-operationBased-simple_union 834 12 148.304004ms +kotlin-compat-named_fragment_with_variables 833 17 759.919722ms +java-operationBased-fragments_same_type_condition 814 37 472.895361ms +kotlin-compat-nested_conditional_inline 812 19 775.284516ms +java-operationBased-hero_details 810 12 196.495057ms +java-operationBased-deprecated_merged_field 803 23 164.822625ms +kotlin-operationBased-named_fragment_delegate 803 23 760.762185ms +java-operationBased-fieldset_with_multiple_super 797 7 152.198627ms +java-operationBased-not_all_combinations_are_needed 795 6 93.042229ms +java-operationBased-simple_inline_fragment 792 5 92.714321ms +java-operationBased-inline_fragment_with_include_directive 784 8 168.831124ms +java-operationBased-test_inline 761 6 96.544481ms +kotlin-responseBased-input_object_type 755 18 807.057433ms +java-operationBased-union_fragment 752 6 139.810673ms +java-operationBased-inline_fragment_inside_inline_fragment 749 6 111.373164ms +kotlin-compat-multiple_fragments 748 18 557.518967ms +kotlin-operationBased-named_fragment_with_variables 746 45 643.201924ms +kotlin-operationBased-nested_conditional_inline 746 23 726.290437ms +kotlin-responseBased-mutation_create_review_semantic_naming 741 23 610.650685ms +kotlin-responseBased-fragment_spread_with_nested_fields 723 23 826.505488ms +kotlin-responseBased-nested_field_with_multiple_fieldsets 716 25 555.726674ms +kotlin-compat-fragments_with_type_condition 709 14 743.480564ms +kotlin-operationBased-fragment_used_twice 701 15 790.975169ms +java-operationBased-named_fragment_without_implementation 681 7 119.484470ms +kotlin-operationBased-nested_field_with_multiple_fieldsets 677 15 620.353205ms +java-operationBased-fragment_with_multiple_fieldsets 675 26 346.704930ms +java-operationBased-hero_details_semantic_naming 675 8 106.944065ms +kotlin-responseBased-simple_fragment 674 13 577.048824ms +kotlin-operationBased-inline_fragment_merge_fields 667 14 588.191752ms +kotlin-responseBased-two_heroes_with_friends 661 15 479.414449ms +kotlin-operationBased-multiple_fragments 659 14 551.688141ms +java-operationBased-path_vs_flat_accessors 658 5 105.487549ms +kotlin-compat-simple_fragment_with_inline_fragments 639 13 545.918596ms +java-operationBased-reserved_keywords 635 6 100.818145ms +java-operationBased-typename_always_first 630 4 95.902043ms +kotlin-responseBased-inline_fragments_with_friends 626 12 664.180006ms +kotlin-operationBased-root_query_inline_fragment 623 24 540.795793ms +kotlin-operationBased-fragments_with_type_condition 621 51 1.169929332s +kotlin-operationBased-named_fragment_inside_inline_fragment 618 19 594.268428ms +kotlin-compat-nested_field_with_multiple_fieldsets 616 19 537.166153ms +kotlin-compat-named_fragment_inside_inline_fragment 613 13 504.367394ms +java-operationBased-interface_on_interface 610 4 105.715446ms +kotlin-compat-simple_fragment 610 10 482.788672ms +kotlin-compat-inline_fragments_with_friends 606 21 614.183909ms +java-operationBased-introspection_query 605 5 129.048413ms +kotlin-responseBased-deprecated_merged_field 602 38 954.820954ms +kotlin-responseBased-simple_union 601 18 415.394648ms +kotlin-responseBased-root_query_inline_fragment 595 14 589.730742ms +kotlin-compat-fragment_spread_with_nested_fields 594 20 765.662607ms +kotlin-responseBased-named_fragment_inside_inline_fragment 589 13 484.023183ms +java-operationBased-root_query_fragment 584 6 85.461299ms +kotlin-compat-fragment_spread_with_include_directive 583 18 674.592395ms +kotlin-operationBased-inline_fragments_with_friends 573 17 603.631905ms +java-operationBased-input_object_variable_and_argument 569 6 141.652059ms +java-operationBased-interface_always_nested 565 4 89.603951ms +kotlin-operationBased-simple_fragment_with_inline_fragments 565 14 463.229239ms +kotlin-compat-root_query_inline_fragment 563 9 509.038608ms +kotlin-operationBased-fragment_spread_with_nested_fields 554 23 714.321122ms +kotlin-responseBased-fragments_same_type_condition 553 18 1.015255655s +java-operationBased-deprecation 544 9 163.702844ms +kotlin-compat-simple_union 542 14 431.343816ms +kotlin-compat-inline_fragment_with_include_directive 540 14 763.612727ms +kotlin-operationBased-fragment_spread_with_include_directive 539 17 660.487325ms +java-operationBased-recursive_selection 538 4 83.346274ms +java-operationBased-hero_with_review 529 6 134.408130ms +kotlin-compat-union_fragment 529 14 440.414954ms +kotlin-compat-deprecated_merged_field 528 36 969.865244ms +kotlin-responseBased-test_inline 527 15 536.373357ms +kotlin-compat-not_all_combinations_are_needed 526 15 508.910291ms +kotlin-compat-fragments_same_type_condition 524 17 832.505564ms +kotlin-operationBased-simple_fragment 522 11 396.251773ms +kotlin-compat-inline_fragment_inside_inline_fragment 521 9 508.692766ms +kotlin-responseBased-fragment_with_multiple_fieldsets 512 11 852.724498ms +kotlin-compat-fieldset_with_multiple_super 511 12 788.844063ms +kotlin-responseBased-union_fragment 508 10 426.441075ms +java-operationBased-field_with_include_directive 507 6 123.257763ms +java-operationBased-hero_name_query_long_name 504 7 124.201167ms +java-operationBased-variable_default_value 504 4 129.144426ms +java-operationBased-hero_name 503 7 98.496378ms +kotlin-operationBased-simple_union 498 10 511.893659ms +kotlin-operationBased-inline_fragment_inside_inline_fragment 489 11 617.689857ms +kotlin-operationBased-inline_fragment_with_include_directive 489 15 626.193794ms +kotlin-responseBased-inline_fragment_merge_fields 488 8 463.086657ms +kotlin-responseBased-hero_details 487 11 876.112222ms +kotlin-compat-inline_fragment_merge_fields 486 10 466.962013ms +java-operationBased-custom_scalar_type 484 8 161.483218ms +kotlin-operationBased-fieldset_with_multiple_super 483 15 644.483371ms +kotlin-responseBased-inline_fragment_inside_inline_fragment 482 12 559.747359ms +kotlin-compat-named_fragment_without_implementation 481 16 530.457366ms +kotlin-operationBased-fragments_same_type_condition 480 19 914.494178ms +java-operationBased-optional 479 4 85.677460ms +kotlin-operationBased-simple_inline_fragment 478 9 459.752823ms +kotlin-operationBased-union_fragment 478 8 402.014498ms +kotlin-operationBased-not_all_combinations_are_needed 475 11 568.036960ms +kotlin-operationBased-deprecated_merged_field 472 24 834.182667ms +java-operationBased-inline_fragment_for_non_optional_field 471 4 89.689422ms +kotlin-responseBased-fieldset_with_multiple_super 470 11 582.875924ms +kotlin-responseBased-named_fragment_without_implementation 470 17 552.006559ms +kotlin-responseBased-simple_inline_fragment 468 8 459.318735ms +kotlin-compat-test_inline 468 11 425.556920ms +java-operationBased-inline_fragment_type_coercion 466 6 122.025833ms +java-operationBased-java8annotation 464 5 84.493779ms +java-operationBased-two_heroes_unique 459 4 93.103708ms +kotlin-compat-fragment_with_multiple_fieldsets 448 14 547.619197ms +kotlin-responseBased-not_all_combinations_are_needed 447 9 411.550920ms +kotlin-responseBased-reserved_keywords 445 14 487.623799ms +kotlin-operationBased-test_inline 445 9 424.315127ms +kotlin-compat-simple_inline_fragment 444 7 435.620287ms +kotlin-operationBased-named_fragment_without_implementation 437 23 580.443700ms +kotlin-responseBased-path_vs_flat_accessors 422 7 494.537595ms +kotlin-compat-reserved_keywords 422 10 416.866545ms +kotlin-operationBased-reserved_keywords 415 11 436.058422ms +java-operationBased-starships 411 4 70.620466ms +kotlin-responseBased-hero_details_semantic_naming 409 31 876.294592ms +kotlin-compat-path_vs_flat_accessors 405 7 425.799622ms +kotlin-responseBased-interface_on_interface 400 7 494.593775ms +java-operationBased-subscriptions 400 4 81.054253ms +kotlin-responseBased-typename_always_first 400 7 374.674801ms +kotlin-operationBased-fragment_with_multiple_fieldsets 398 9 540.024364ms +java-operationBased-antlr_tokens 397 21 196.313285ms +kotlin-operationBased-path_vs_flat_accessors 391 7 386.073163ms +kotlin-responseBased-root_query_fragment 388 8 359.293453ms +kotlin-responseBased-input_object_variable_and_argument 387 8 507.656954ms +kotlin-operationBased-typename_always_first 387 7 373.906772ms +kotlin-compat-typename_always_first 387 8 448.826456ms +kotlin-compat-root_query_fragment 386 9 347.734235ms +kotlin-compat-interface_on_interface 378 7 417.940935ms +kotlin-responseBased-hero_name 376 8 475.387300ms +java-operationBased-arguments_hardcoded 374 9 185.600013ms +kotlin-operationBased-interface_on_interface 371 18 380.662260ms +kotlin-responseBased-interface_always_nested 368 15 428.410113ms +kotlin-responseBased-hero_with_review 358 8 594.364734ms +java-operationBased-merged_include 354 3 77.035139ms +kotlin-compat-interface_always_nested 353 27 531.487514ms +java-operationBased-operation_id_generator 353 4 85.510638ms +kotlin-responseBased-deprecation 350 14 654.411677ms +kotlin-responseBased-hero_name_query_long_name 348 8 526.380818ms +kotlin-compat-hero_name 344 6 415.831317ms +kotlin-operationBased-root_query_fragment 342 7 341.274286ms +java-operationBased-case_sensitive_enum 341 7 156.741003ms +java-operationBased-enum_field 341 4 86.308179ms +java-operationBased-enums_as_sealed 341 6 111.624176ms +kotlin-responseBased-custom_scalar_type 339 15 775.582687ms +kotlin-operationBased-interface_always_nested 339 13 460.386153ms +java-operationBased-nonnull 335 4 84.742430ms +kotlin-responseBased-inline_fragment_for_non_optional_field 332 6 492.093346ms +kotlin-responseBased-introspection_query 332 8 407.840728ms +kotlin-responseBased-field_with_include_directive 318 11 556.677654ms +kotlin-responseBased-variable_default_value 317 6 351.712890ms +kotlin-operationBased-hero_name 316 6 470.435337ms +kotlin-responseBased-inline_fragment_type_coercion 314 6 499.970737ms +kotlin-compat-inline_fragment_for_non_optional_field 303 5 474.162753ms +kotlin-responseBased-recursive_selection 302 8 373.245746ms +kotlin-responseBased-optional 298 6 364.584066ms +kotlin-compat-inline_fragment_type_coercion 290 5 354.287389ms +kotlin-operationBased-inline_fragment_for_non_optional_field 286 7 441.693305ms +kotlin-operationBased-inline_fragment_type_coercion 276 5 421.300152ms +kotlin-responseBased-two_heroes_unique 273 6 341.144056ms +kotlin-responseBased-java8annotation 266 7 320.974747ms +kotlin-responseBased-starships 263 6 361.522898ms +kotlin-responseBased-antlr_tokens 256 52 805.873599ms +kotlin-responseBased-subscriptions 252 5 307.238771ms +kotlin-responseBased-arguments_hardcoded 245 14 711.344900ms +kotlin-responseBased-enums_as_sealed 225 10 443.764794ms +kotlin-responseBased-operation_id_generator 207 4 366.508510ms +kotlin-responseBased-merged_include 206 4 324.697128ms +kotlin-responseBased-nonnull 191 6 374.692249ms +kotlin-responseBased-case_sensitive_enum 190 11 719.708495ms +kotlin-responseBased-enum_field 189 8 515.163121ms +kotlin-responseBased-empty 0 0 220.130773ms +java-operationBased-empty 0 0 8.015us \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected index 7b57b810294..2333959d982 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/TestQuery.kt.expected @@ -36,7 +36,7 @@ public class TestQuery() : Query { public override fun selections(): List = TestQuerySelections.root public data class Data( - public val yield_: Yield?, + public val `yield`: Yield?, public val objects: List? ) : Query.Data { public fun objectsFilterNotNull(): List? = objects?.filterNotNull() diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index c57f91bd1de..c43c03326e9 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -26,12 +26,12 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var yield_: TestQuery.Yield? = null + var `yield`: TestQuery.Yield? = null var objects: List? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> yield_ = Yield.obj().nullable().fromJson(reader, customScalarAdapters) + 0 -> `yield` = Yield.obj().nullable().fromJson(reader, customScalarAdapters) 1 -> objects = Object.obj(true).nullable().list().nullable().fromJson(reader, customScalarAdapters) else -> break @@ -39,7 +39,7 @@ public object TestQuery_ResponseAdapter { } return TestQuery.Data( - yield_ = yield_, + `yield` = `yield`, objects = objects ) } @@ -50,7 +50,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("yield") - Yield.obj().nullable().toJson(writer, customScalarAdapters, value.yield_) + Yield.obj().nullable().toJson(writer, customScalarAdapters, value.`yield`) writer.name("objects") Object.obj(true).nullable().list().nullable().toJson(writer, customScalarAdapters, diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected index 72bb5f5aab1..21e5f1ea451 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/compat/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -18,7 +18,7 @@ import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { - private val yield_: List = listOf( + private val `yield`: List = listOf( CompiledField.Builder( name = "id", type = CompiledIDType.notNull() @@ -54,7 +54,7 @@ public object TestQuerySelections { name = "hero", type = Character.type ).alias("yield") - .selections(yield_) + .selections(`yield`) .build(), CompiledField.Builder( name = "search", diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected index 76fd4718e99..8cfec7f95e8 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/TestQuery.kt.expected @@ -36,7 +36,7 @@ public class TestQuery() : Query { public override fun selections(): List = TestQuerySelections.root public data class Data( - public val yield_: Yield?, + public val `yield`: Yield?, public val objects: List? ) : Query.Data { public fun objectsFilterNotNull(): List? = objects?.filterNotNull() diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index bb1719c120d..7373df152d3 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -26,12 +26,12 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var yield_: TestQuery.Data.Yield? = null + var `yield`: TestQuery.Data.Yield? = null var objects: List? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> yield_ = Yield.obj().nullable().fromJson(reader, customScalarAdapters) + 0 -> `yield` = Yield.obj().nullable().fromJson(reader, customScalarAdapters) 1 -> objects = Object.obj(true).nullable().list().nullable().fromJson(reader, customScalarAdapters) else -> break @@ -39,7 +39,7 @@ public object TestQuery_ResponseAdapter { } return TestQuery.Data( - yield_ = yield_, + `yield` = `yield`, objects = objects ) } @@ -50,7 +50,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("yield") - Yield.obj().nullable().toJson(writer, customScalarAdapters, value.yield_) + Yield.obj().nullable().toJson(writer, customScalarAdapters, value.`yield`) writer.name("objects") Object.obj(true).nullable().list().nullable().toJson(writer, customScalarAdapters, diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 72bb5f5aab1..21e5f1ea451 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/operationBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -18,7 +18,7 @@ import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { - private val yield_: List = listOf( + private val `yield`: List = listOf( CompiledField.Builder( name = "id", type = CompiledIDType.notNull() @@ -54,7 +54,7 @@ public object TestQuerySelections { name = "hero", type = Character.type ).alias("yield") - .selections(yield_) + .selections(`yield`) .build(), CompiledField.Builder( name = "search", diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected index 5c285c4c17b..39497a95378 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/TestQuery.kt.expected @@ -36,7 +36,7 @@ public class TestQuery() : Query { public override fun selections(): List = TestQuerySelections.root public data class Data( - public val yield_: Yield?, + public val `yield`: Yield?, public val objects: List? ) : Query.Data { public fun objectsFilterNotNull(): List? = objects?.filterNotNull() diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected index d23b64689cd..ef1d09fb3ec 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/adapter/TestQuery_ResponseAdapter.kt.expected @@ -24,12 +24,12 @@ public object TestQuery_ResponseAdapter { public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): TestQuery.Data { - var yield_: TestQuery.Data.Yield? = null + var `yield`: TestQuery.Data.Yield? = null var objects: List? = null while(true) { when (reader.selectName(RESPONSE_NAMES)) { - 0 -> yield_ = Yield.obj().nullable().fromJson(reader, customScalarAdapters) + 0 -> `yield` = Yield.obj().nullable().fromJson(reader, customScalarAdapters) 1 -> objects = Object.obj().nullable().list().nullable().fromJson(reader, customScalarAdapters) else -> break @@ -37,7 +37,7 @@ public object TestQuery_ResponseAdapter { } return TestQuery.Data( - yield_ = yield_, + `yield` = `yield`, objects = objects ) } @@ -48,7 +48,7 @@ public object TestQuery_ResponseAdapter { `value`: TestQuery.Data ): Unit { writer.name("yield") - Yield.obj().nullable().toJson(writer, customScalarAdapters, value.yield_) + Yield.obj().nullable().toJson(writer, customScalarAdapters, value.`yield`) writer.name("objects") Object.obj().nullable().list().nullable().toJson(writer, customScalarAdapters, value.objects) diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected index 72bb5f5aab1..21e5f1ea451 100644 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected +++ b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/kotlin/responseBased/reserved_keywords/selections/TestQuerySelections.kt.expected @@ -18,7 +18,7 @@ import com.example.reserved_keywords.type.SearchResult import kotlin.collections.List public object TestQuerySelections { - private val yield_: List = listOf( + private val `yield`: List = listOf( CompiledField.Builder( name = "id", type = CompiledIDType.notNull() @@ -54,7 +54,7 @@ public object TestQuerySelections { name = "hero", type = Character.type ).alias("yield") - .selections(yield_) + .selections(`yield`) .build(), CompiledField.Builder( name = "search", diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 10a5d465a1e..ea61ed23b35 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -85,7 +85,7 @@ ext.dep = [ okioNodeJs: "com.squareup.okio:okio-nodefilesystem:$versions.okio", poet : [ java : "com.squareup:javapoet:$versions.javaPoet", - kotlin: "com.squareup:kotlinpoet:1.9.0", + kotlin: "com.squareup:kotlinpoet:1.10.2", ], rx2 : "io.reactivex.rxjava2:rxjava:$versions.rxjava", rx3 : "io.reactivex.rxjava3:rxjava:$versions.rxjava3", diff --git a/tests/escaping/src/test/kotlin/test/EscapingTest.kt b/tests/escaping/src/test/kotlin/test/EscapingTest.kt index ee0e51177a1..1c200490f68 100644 --- a/tests/escaping/src/test/kotlin/test/EscapingTest.kt +++ b/tests/escaping/src/test/kotlin/test/EscapingTest.kt @@ -13,7 +13,7 @@ class EscapingTest { `return` = "public", `for` = Do( `if` = Optional.Absent, - yield_ = Optional.Absent, + yield = Optional.Absent, ), )) .execute() From e3c7de8ddada712c6aaafb3b5aafb66a635bd61d Mon Sep 17 00:00:00 2001 From: BoD Date: Wed, 1 Dec 2021 17:37:02 +0100 Subject: [PATCH 7/7] Make "enum value names" function naming less confusing --- .../apollo3/compiler/codegen/CodegenLayout.kt | 5 +---- .../apollo3/compiler/codegen/java/JavaCodegenLayout.kt | 4 ++++ .../compiler/codegen/kotlin/KotlinCodegenLayout.kt | 10 +++++++++- .../compiler/codegen/kotlin/file/EnumAsEnumBuilder.kt | 3 +-- .../codegen/kotlin/file/EnumAsSealedBuilder.kt | 6 +++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt index a2cc40b9e00..1a09e37d214 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/CodegenLayout.kt @@ -52,9 +52,6 @@ abstract class CodegenLayout( internal fun enumName(name: String) = regularIdentifier(name) - // We used to write upper case enum values but the server can define different values with different cases - // See https://github.com/apollographql/apollo-android/issues/3035 - internal fun enumValueName(name: String) = regularIdentifier(name) internal fun enumResponseAdapterName(name: String) = enumName(name) + "_ResponseAdapter" internal fun operationName(operation: IrOperation): String { @@ -93,7 +90,7 @@ abstract class CodegenLayout( abstract fun escapeReservedWord(word: String): String - private fun regularIdentifier(name: String) = escapeReservedWord(name) + internal fun regularIdentifier(name: String) = escapeReservedWord(name) private fun capitalizedIdentifier(name: String): String { return escapeReservedWord(name.capitalizeFirstLetter()) } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt index 2b3972c361d..642759ef682 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/java/JavaCodegenLayout.kt @@ -10,4 +10,8 @@ class JavaCodegenLayout( useSemanticNaming: Boolean, ) : CodegenLayout(packageNameGenerator, schemaPackageName, useSemanticNaming) { override fun escapeReservedWord(word: String): String = word.escapeJavaReservedWord() + + // We used to write upper case enum values but the server can define different values with different cases + // See https://github.com/apollographql/apollo-android/issues/3035 + internal fun enumValueName(name: String) = regularIdentifier(name) } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt index 7cc65ee4cbf..0fcfb803082 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/KotlinCodegenLayout.kt @@ -13,5 +13,13 @@ class KotlinCodegenLayout( override fun escapeReservedWord(word: String): String = word.escapeKotlinReservedWord() - internal fun sealedClassValueName(name: String) = name.escapeKotlinReservedEnumValueNames() + /** + * Enum value name to use when generating enums as sealed classes + */ + internal fun enumAsSealedClassValueName(name: String) = regularIdentifier(name) + + /** + * Enum value name to use when generating enums as enums + */ + internal fun enumAsEnumValueName(name: String) = name.escapeKotlinReservedEnumValueNames() } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsEnumBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsEnumBuilder.kt index 3046b981a82..dcd7f2458e7 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsEnumBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsEnumBuilder.kt @@ -6,7 +6,6 @@ import com.apollographql.apollo3.compiler.codegen.kotlin.CgOutputFileBuilder import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.maybeAddDeprecation import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.maybeAddDescription -import com.apollographql.apollo3.compiler.escapeKotlinReservedEnumValueNames import com.apollographql.apollo3.compiler.ir.IrEnum import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FunSpec @@ -51,7 +50,7 @@ class EnumAsEnumBuilder( .addType(companionTypeSpec()) .apply { values.forEach { value -> - addEnumConstant(layout.sealedClassValueName(value.name), value.enumConstTypeSpec()) + addEnumConstant(layout.enumAsEnumValueName(value.name), value.enumConstTypeSpec()) } addEnumConstant("UNKNOWN__", unknownValueTypeSpec()) } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsSealedBuilder.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsSealedBuilder.kt index e79c63bb13f..7ad35718cb2 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsSealedBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/codegen/kotlin/file/EnumAsSealedBuilder.kt @@ -5,8 +5,8 @@ import com.apollographql.apollo3.compiler.codegen.Identifier.knownValues import com.apollographql.apollo3.compiler.codegen.Identifier.safeValueOf import com.apollographql.apollo3.compiler.codegen.kotlin.CgFile import com.apollographql.apollo3.compiler.codegen.kotlin.CgOutputFileBuilder -import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinContext +import com.apollographql.apollo3.compiler.codegen.kotlin.KotlinSymbols import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.deprecatedAnnotation import com.apollographql.apollo3.compiler.codegen.kotlin.helpers.maybeAddDescription import com.apollographql.apollo3.compiler.ir.IrEnum @@ -74,7 +74,7 @@ class EnumAsSealedBuilder( } private fun IrEnum.Value.toObjectTypeSpec(superClass: TypeName): TypeSpec { - return TypeSpec.objectBuilder(layout.enumValueName(name)) + return TypeSpec.objectBuilder(layout.enumAsSealedClassValueName(name)) .applyIf(description?.isNotBlank() == true) { addKdoc("%L\n", description!!) } .applyIf(deprecationReason != null) { addAnnotation(deprecatedAnnotation(deprecationReason!!)) } .superclass(superClass) @@ -151,7 +151,7 @@ class EnumAsSealedBuilder( } private fun IrEnum.Value.valueClassName(): ClassName { - return ClassName(packageName, simpleName, layout.enumValueName(name)) + return ClassName(packageName, simpleName, layout.enumAsSealedClassValueName(name)) } private fun unknownValueClassName(): ClassName {