Skip to content
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

Disable service-loading ApolloCompilerPlugin #6059

Merged
merged 3 commits into from
Jul 15, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import com.apollographql.apollo.compiler.ir.IrOperations
import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor
import com.apollographql.apollo.compiler.operationoutput.OperationId

@Deprecated(
"Use ApolloCompilerPlugin instead (don't forget to replace the META-INF.service file to `com.apollographql.apollo.compiler.ApolloCompilerPlugin`",
ReplaceWith("ApolloCompilerPlugin"),
DeprecationLevel.ERROR
)
typealias Plugin = ApolloCompilerPlugin

/**
* [ApolloCompilerPlugin] allows to customize the behaviour of the Apollo Compiler.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal fun apolloCompilerPlugin(

val plugin = plugins.singleOrNull()
if (plugin != null) {
return plugin
error("Apollo: use ApolloCompilerPluginProvider instead of ApolloCompilerPlugin directly. ApolloCompilerPluginProvider allows arguments and logging")
}

val pluginProviders = ServiceLoader.load(ApolloCompilerPluginProvider::class.java).toList()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
package apollo.plugin

import com.apollographql.apollo.annotations.ApolloExperimental
import com.apollographql.apollo.compiler.OperationOutputGenerator
import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor
import com.apollographql.apollo.compiler.operationoutput.OperationId

class MyPlugin: ApolloCompilerPlugin {
override fun operationIds(descriptors: List<OperationDescriptor>): List<OperationId>? {
return descriptors.map { OperationId("${it.name}CustomId", it.name) }
}
}

@OptIn(ApolloExperimental::class)
class MyPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return MyPlugin()
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apollo.plugin.MyPluginProvider
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ import com.apollographql.apollo.ast.responseName
import com.apollographql.apollo.ast.rootTypeDefinition
import com.apollographql.apollo.compiler.DocumentTransform
import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}

class TestPlugin : ApolloCompilerPlugin {
override fun documentTransform(): DocumentTransform {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package hooks

import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.Transform
import com.apollographql.apollo.compiler.codegen.kotlin.KotlinOutput
import com.squareup.kotlinpoet.FunSpec
import com.squareup.kotlinpoet.TypeSpec

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}

class TestPlugin : ApolloCompilerPlugin {
override fun kotlinOutputTransform(): Transform<KotlinOutput> {
return object : Transform<KotlinOutput> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package hooks

import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.Transform
import com.apollographql.apollo.compiler.ir.IrOperations

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}

class TestPlugin : ApolloCompilerPlugin {
override fun irOperationsTransform(): Transform<IrOperations> {
return object : Transform<IrOperations> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package hooks

import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.Transform
import com.apollographql.apollo.compiler.codegen.kotlin.KotlinOutput
import com.squareup.kotlinpoet.CodeBlock
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.TypeSpec

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}

class TestPlugin: ApolloCompilerPlugin {
override fun kotlinOutputTransform(): Transform<KotlinOutput> {
return object : Transform<KotlinOutput> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package hooks

import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.Transform
import com.apollographql.apollo.compiler.capitalizeFirstLetter
import com.apollographql.apollo.compiler.codegen.java.JavaOutput
import com.squareup.javapoet.JavaFile
import com.squareup.javapoet.MethodSpec
import javax.lang.model.element.Modifier

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}
class TestPlugin : ApolloCompilerPlugin {
override fun javaOutputTransform(): Transform<JavaOutput> {
return object : Transform<JavaOutput> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
package hooks

import com.apollographql.apollo.compiler.ApolloCompilerPlugin
import com.apollographql.apollo.compiler.ApolloCompilerPluginEnvironment
import com.apollographql.apollo.compiler.ApolloCompilerPluginProvider
import com.apollographql.apollo.compiler.Transform
import com.apollographql.apollo.compiler.codegen.kotlin.KotlinOutput
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.KModifier
import com.squareup.kotlinpoet.TypeSpec

class TestPluginProvider: ApolloCompilerPluginProvider {
override fun create(environment: ApolloCompilerPluginEnvironment): ApolloCompilerPlugin {
return TestPlugin()
}
}

class TestPlugin : ApolloCompilerPlugin {
private val interfaceName = "hooks.typenameinterface.HasTypeName"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hooks.TestPluginProvider
Loading