Skip to content

Keep main in sync with v4 #6541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/apollo-annotations/api/apollo-annotations.api
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public final class com/apollographql/apollo/annotations/ApolloDeprecatedSince$Ve
public static final field v4_0_1 Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
public static final field v4_0_2 Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
public static final field v4_1_2 Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
public static final field v4_2_1 Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
public static final field v5_0_0 Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/apollographql/apollo/annotations/ApolloDeprecatedSince$Version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ open annotation class com.apollographql.apollo.annotations/ApolloDeprecatedSince
enum entry v4_0_1 // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.v4_0_1|null[0]
enum entry v4_0_2 // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.v4_0_2|null[0]
enum entry v4_1_2 // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.v4_1_2|null[0]
enum entry v4_2_1 // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.v4_2_1|null[0]
enum entry v5_0_0 // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.v5_0_0|null[0]

final val entries // com.apollographql.apollo.annotations/ApolloDeprecatedSince.Version.entries|#static{}entries[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ annotation class ApolloDeprecatedSince(val version: Version) {
v4_0_1,
v4_0_2,
v4_1_2, // All symbols above are ERRORs in 5.0.0 except a few ones that are perpetual soft deprecations like SubscriptionWsProtocol (https://youtrack.jetbrains.com/issue/KT-54106)
v4_2_1,
v5_0_0
}
}
31 changes: 18 additions & 13 deletions libraries/apollo-compiler/api/apollo-compiler.api
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public final class com/apollographql/apollo/compiler/After : com/apollographql/a

public final class com/apollographql/apollo/compiler/ApolloCompiler {
public static final field INSTANCE Lcom/apollographql/apollo/compiler/ApolloCompiler;
public final fun buildCodegenSchema (Ljava/util/List;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;Lcom/apollographql/apollo/compiler/CodegenSchemaOptions;Ljava/util/List;Lcom/apollographql/apollo/compiler/SchemaTransform;)Lcom/apollographql/apollo/compiler/CodegenSchema;
public final fun buildCodegenSchema (Ljava/util/List;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;Lcom/apollographql/apollo/compiler/CodegenSchemaOptions;Ljava/util/List;Lcom/apollographql/apollo/compiler/SchemaDocumentTransform;)Lcom/apollographql/apollo/compiler/CodegenSchema;
public final fun buildDataBuilders (Lcom/apollographql/apollo/compiler/CodegenSchema;Lcom/apollographql/apollo/compiler/UsedCoordinates;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/codegen/SchemaLayout;Ljava/util/List;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
public final fun buildIrOperations (Lcom/apollographql/apollo/compiler/CodegenSchema;Ljava/util/List;Ljava/util/List;Ljava/util/List;Lcom/apollographql/apollo/compiler/IrOptions;Lcom/apollographql/apollo/compiler/ExecutableDocumentTransform;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;)Lcom/apollographql/apollo/compiler/ir/IrOperations;
public final fun buildSchemaAndOperationsSources (Lcom/apollographql/apollo/compiler/CodegenSchema;Ljava/util/List;Lcom/apollographql/apollo/compiler/IrOptions;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/LayoutFactory;Lcom/apollographql/apollo/compiler/OperationIdsGenerator;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/ExecutableDocumentTransform;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;Ljava/io/File;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
public final fun buildSchemaAndOperationsSources (Ljava/util/List;Ljava/util/List;Lcom/apollographql/apollo/compiler/CodegenSchemaOptions;Lcom/apollographql/apollo/compiler/IrOptions;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/LayoutFactory;Lcom/apollographql/apollo/compiler/OperationIdsGenerator;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/ExecutableDocumentTransform;Lcom/apollographql/apollo/compiler/SchemaTransform;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;Ljava/io/File;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
public final fun buildSchemaAndOperationsSources (Ljava/util/List;Ljava/util/List;Lcom/apollographql/apollo/compiler/CodegenSchemaOptions;Lcom/apollographql/apollo/compiler/IrOptions;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/LayoutFactory;Lcom/apollographql/apollo/compiler/OperationIdsGenerator;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/ExecutableDocumentTransform;Lcom/apollographql/apollo/compiler/SchemaDocumentTransform;Lcom/apollographql/apollo/compiler/ApolloCompiler$Logger;Ljava/io/File;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
public final fun buildSchemaAndOperationsSourcesFromIr (Lcom/apollographql/apollo/compiler/CodegenSchema;Lcom/apollographql/apollo/compiler/ir/IrOperations;Lcom/apollographql/apollo/compiler/UsedCoordinates;Ljava/util/List;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/codegen/SchemaAndOperationsLayout;Lcom/apollographql/apollo/compiler/OperationIdsGenerator;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;Ljava/io/File;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
public final fun buildSchemaSources (Lcom/apollographql/apollo/compiler/CodegenSchema;Lcom/apollographql/apollo/compiler/UsedCoordinates;Lcom/apollographql/apollo/compiler/CodegenOptions;Lcom/apollographql/apollo/compiler/codegen/SchemaLayout;Lcom/apollographql/apollo/compiler/Transform;Lcom/apollographql/apollo/compiler/Transform;)Lcom/apollographql/apollo/compiler/codegen/SourceOutput;
}
Expand Down Expand Up @@ -54,25 +54,21 @@ public abstract interface class com/apollographql/apollo/compiler/ApolloCompiler

public abstract interface class com/apollographql/apollo/compiler/ApolloCompilerRegistry {
public abstract fun registerExecutableDocumentTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/ExecutableDocumentTransform;)V
public abstract fun registerExtraCodeGenerator (Lcom/apollographql/apollo/compiler/CodeGenerator;)V
public abstract fun registerForeignSchemas (Ljava/util/List;)V
public abstract fun registerIrTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/Transform;)V
public abstract fun registerJavaOutputTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/Transform;)V
public abstract fun registerKotlinOutputTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/Transform;)V
public abstract fun registerLayout (Lcom/apollographql/apollo/compiler/LayoutFactory;)V
public abstract fun registerOperationIdsGenerator (Lcom/apollographql/apollo/compiler/OperationIdsGenerator;)V
public abstract fun registerSchemaTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/SchemaTransform;)V
public abstract fun registerSchemaCodeGenerator (Lcom/apollographql/apollo/compiler/SchemaCodeGenerator;)V
public abstract fun registerSchemaTransform (Ljava/lang/String;[Lcom/apollographql/apollo/compiler/Order;Lcom/apollographql/apollo/compiler/SchemaDocumentTransform;)V
}

public final class com/apollographql/apollo/compiler/Before : com/apollographql/apollo/compiler/Order {
public fun <init> (Ljava/lang/String;)V
public final fun getId ()Ljava/lang/String;
}

public abstract interface class com/apollographql/apollo/compiler/CodeGenerator {
public abstract fun generate (Lcom/apollographql/apollo/ast/GQLDocument;Ljava/io/File;)V
}

public final class com/apollographql/apollo/compiler/CodegenMetadata {
public static final field Companion Lcom/apollographql/apollo/compiler/CodegenMetadata$Companion;
public fun <init> (Ljava/lang/String;Lcom/apollographql/apollo/compiler/TargetLanguage;Ljava/util/List;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;Ljava/util/Map;)V
Expand Down Expand Up @@ -201,6 +197,11 @@ public abstract interface class com/apollographql/apollo/compiler/CommonCodegenO
public abstract fun getUseSemanticNaming ()Ljava/lang/Boolean;
}

public abstract interface class com/apollographql/apollo/compiler/DocumentTransform {
public abstract fun transform (Lcom/apollographql/apollo/ast/Schema;Lcom/apollographql/apollo/ast/GQLFragmentDefinition;)Lcom/apollographql/apollo/ast/GQLFragmentDefinition;
public abstract fun transform (Lcom/apollographql/apollo/ast/Schema;Lcom/apollographql/apollo/ast/GQLOperationDefinition;)Lcom/apollographql/apollo/ast/GQLOperationDefinition;
}

public final class com/apollographql/apollo/compiler/EntryPoints {
public fun <init> ()V
public final fun buildCodegenSchema (Ljava/util/Map;IZLjava/util/List;Ljava/util/function/Consumer;Ljava/io/File;Ljava/io/File;)V
Expand Down Expand Up @@ -364,7 +365,7 @@ public abstract interface class com/apollographql/apollo/compiler/LayoutFactory
}

public abstract interface class com/apollographql/apollo/compiler/OperationIdsGenerator {
public abstract fun generate (Ljava/util/Collection;)Ljava/util/List;
public abstract fun generate (Ljava/util/List;)Ljava/util/List;
}

public abstract interface class com/apollographql/apollo/compiler/OperationsCodegenOpt {
Expand Down Expand Up @@ -401,6 +402,10 @@ public final class com/apollographql/apollo/compiler/RuntimeAdapterInitializer :
public final fun serializer ()Lkotlinx/serialization/KSerializer;
}

public abstract interface class com/apollographql/apollo/compiler/SchemaCodeGenerator {
public abstract fun generate (Lcom/apollographql/apollo/ast/GQLDocument;Ljava/io/File;)V
}

public abstract interface class com/apollographql/apollo/compiler/SchemaCodegenOpt {
public abstract fun getGenerateSchema ()Ljava/lang/Boolean;
public abstract fun getGeneratedSchemaName ()Ljava/lang/String;
Expand All @@ -409,12 +414,12 @@ public abstract interface class com/apollographql/apollo/compiler/SchemaCodegenO
public abstract interface class com/apollographql/apollo/compiler/SchemaCodegenOptions : com/apollographql/apollo/compiler/JavaSchemaCodegenOptions, com/apollographql/apollo/compiler/KotlinSchemaCodegenOptions {
}

public abstract interface class com/apollographql/apollo/compiler/SchemaListener {
public abstract fun onSchema (Lcom/apollographql/apollo/ast/Schema;Ljava/io/File;)V
public abstract interface class com/apollographql/apollo/compiler/SchemaDocumentTransform {
public abstract fun transform (Lcom/apollographql/apollo/ast/GQLDocument;)Lcom/apollographql/apollo/ast/GQLDocument;
}

public abstract interface class com/apollographql/apollo/compiler/SchemaTransform {
public abstract fun transform (Lcom/apollographql/apollo/ast/GQLDocument;)Lcom/apollographql/apollo/ast/GQLDocument;
public abstract interface class com/apollographql/apollo/compiler/SchemaListener {
public abstract fun onSchema (Lcom/apollographql/apollo/ast/Schema;Ljava/io/File;)V
}

public final class com/apollographql/apollo/compiler/StringsKt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import com.apollographql.apollo.compiler.ir.IrOperationsBuilder
import com.apollographql.apollo.compiler.ir.IrSchemaBuilder
import com.apollographql.apollo.compiler.ir.buildIrDataBuilders
import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor
import com.apollographql.apollo.compiler.operationoutput.OperationId
import com.apollographql.apollo.compiler.operationoutput.toOperationOutput
import com.apollographql.apollo.compiler.pqm.toPersistedQueryManifest
import java.io.File
Expand All @@ -60,7 +59,7 @@ object ApolloCompiler {
logger: Logger?,
codegenSchemaOptions: CodegenSchemaOptions,
foreignSchemas: List<ForeignSchema>,
schemaTransform: SchemaTransform?,
schemaTransform: SchemaDocumentTransform?,
): CodegenSchema {
val schemaDocuments = schemaFiles.map {
it.normalizedPath to it.file.toGQLDocument(allowJson = true)
Expand Down Expand Up @@ -190,7 +189,7 @@ object ApolloCompiler {
upstreamCodegenModels: List<String>,
upstreamFragmentDefinitions: List<GQLFragmentDefinition>,
options: IrOptions,
executableDocumentTransform: ExecutableDocumentTransform?,
documentTransform: ExecutableDocumentTransform?,
logger: Logger?,
): IrOperations {
val schema = codegenSchema.schema
Expand Down Expand Up @@ -232,14 +231,24 @@ object ApolloCompiler {

/**
* Step 2, Modify the AST to add typename, key fields and call any user-provided transform.
* If we detect that the cache compiler plugin is present, we skip adding the keyfields because it will do it.
* TODO: deprecate `addTypename`
*/
var document = ApolloExecutableDocumentTransform(options.addTypename ?: defaultAddTypename).transform(
schema = schema,
document = GQLDocument(userDefinitions, sourceLocation = null),
upstreamFragmentDefinitions
val hasCacheCompilerPlugin = try {
Class.forName("com.apollographql.cache.apollocompilerplugin.internal.ApolloCacheCompilerPlugin")
true
} catch (_: ClassNotFoundException) {
false
}

var document = ApolloExecutableDocumentTransform(options.addTypename ?: defaultAddTypename, !hasCacheCompilerPlugin).transform(
schema = schema,
document = GQLDocument(userDefinitions, sourceLocation = null),
upstreamFragmentDefinitions
)
if (executableDocumentTransform != null) {
document = executableDocumentTransform.transform(schema, document, upstreamFragmentDefinitions)

if (documentTransform != null) {
document = documentTransform.transform(schema, document, upstreamFragmentDefinitions)
}

/**
Expand Down Expand Up @@ -475,8 +484,8 @@ object ApolloCompiler {
irOperationsTransform: Transform<IrOperations>?,
javaOutputTransform: Transform<JavaOutput>?,
kotlinOutputTransform: Transform<KotlinOutput>?,
executableDocumentTransform: ExecutableDocumentTransform?,
schemaTransform: SchemaTransform?,
documentTransform: ExecutableDocumentTransform?,
schemaDocumentTransform: SchemaDocumentTransform?,
logger: Logger?,
operationManifestFile: File?,
): SourceOutput {
Expand All @@ -485,7 +494,7 @@ object ApolloCompiler {
logger = logger,
codegenSchemaOptions = codegenSchemaOptions,
foreignSchemas = emptyList(),
schemaTransform = schemaTransform
schemaTransform = schemaDocumentTransform
)

return buildSchemaAndOperationsSources(
Expand All @@ -498,7 +507,7 @@ object ApolloCompiler {
irOperationsTransform,
javaOutputTransform,
kotlinOutputTransform,
executableDocumentTransform,
documentTransform,
logger,
operationManifestFile
)
Expand All @@ -517,7 +526,7 @@ object ApolloCompiler {
irOperationsTransform: Transform<IrOperations>?,
javaOutputTransform: Transform<JavaOutput>?,
kotlinOutputTransform: Transform<KotlinOutput>?,
executableDocumentTransform: ExecutableDocumentTransform?,
documentTransform: ExecutableDocumentTransform?,
logger: Logger?,
operationManifestFile: File?,
): SourceOutput {
Expand All @@ -526,7 +535,7 @@ object ApolloCompiler {
executableFiles = executableFiles,
upstreamCodegenModels = emptyList(),
upstreamFragmentDefinitions = emptyList(),
executableDocumentTransform = executableDocumentTransform,
documentTransform = documentTransform,
options = irOptions,
logger = logger
)
Expand Down Expand Up @@ -642,6 +651,3 @@ fun interface LayoutFactory {
fun create(codegenSchema: CodegenSchema): SchemaAndOperationsLayout?
}

fun interface OperationIdsGenerator {
fun generate(operationDescriptorList: Collection<OperationDescriptor>): List<OperationId>
}
Loading
Loading