Skip to content

Commit

Permalink
Deprecate "operationOutput" and ./gradlew downloadApolloSchema (#…
Browse files Browse the repository at this point in the history
…6097)

* Deprecate "operationOutput"

* Deprecate ./gradlew downloadApolloSchema
  • Loading branch information
martinbonnin authored Aug 7, 2024
1 parent edc9dbe commit 3af9b79
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/source/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Apollo Kotlin supports three types of files:
- `.json` schema files: describes the types in your backend using the Json syntax.
- `.graphql` executable files: describes your queries and operations in the GraphQL syntax.

By default, Apollo Kotlin requires a schema in your module's `src/main/graphql` (or `src/commonMain/graphql` for KMP) directory. You can download a schema using introspection with the `./gradlew downloadApolloSchema` task. Sometimes introspection is disabled, and you will have to ask your backend team to provide a schema. Copy this schema to your module:
By default, Apollo Kotlin requires a schema in your module's `src/main/graphql` (or `src/commonMain/graphql` for KMP) directory. You can download a schema using introspection using GraphiQL or Studio. Sometimes introspection is disabled, and you will have to ask your backend team to provide a schema. Copy this schema to your module:

```
cp ${schema} ${module}/src/main/graphql/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ annotation class ApolloDeprecatedSince(val version: Version) {
v3_7_2,
v3_7_5,
v4_0_0,
v4_0_1,
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.apollographql.apollo.compiler

import com.apollographql.apollo.annotations.ApolloDeprecatedSince
import com.apollographql.apollo.annotations.ApolloExperimental
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -13,6 +14,8 @@ const val ADD_TYPENAME_IF_POLYMORPHIC = "ifPolymorphic"
const val ADD_TYPENAME_IF_ABSTRACT = "ifAbstract"
const val ADD_TYPENAME_ALWAYS = "always"

@Deprecated("Use $MANIFEST_PERSISTED_QUERY instead")
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_1)
const val MANIFEST_OPERATION_OUTPUT = "operationOutput"
const val MANIFEST_PERSISTED_QUERY = "persistedQueryManifest"
const val MANIFEST_NONE = "none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package com.apollographql.apollo.gradle.api
import com.android.build.gradle.api.BaseVariant
import com.apollographql.apollo.annotations.ApolloDeprecatedSince
import com.apollographql.apollo.annotations.ApolloExperimental
import com.apollographql.apollo.compiler.MANIFEST_PERSISTED_QUERY
import com.apollographql.apollo.compiler.OperationIdGenerator
import com.apollographql.apollo.compiler.OperationOutputGenerator
import com.apollographql.apollo.compiler.PackageNameGenerator
Expand Down Expand Up @@ -542,7 +543,7 @@ interface Service {
*
* Defaults value: false
*/
@Deprecated("Use operationManifestFormat", ReplaceWith("operationManifestFormat.set(\"operationOutput\""))
@Deprecated("Use operationManifestFormat", ReplaceWith("operationManifestFormat.set(\"$MANIFEST_PERSISTED_QUERY\")"))
@ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0)
val generateOperationOutput: Property<Boolean>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.apollographql.apollo.compiler.ExpressionAdapterInitializer
import com.apollographql.apollo.compiler.GeneratedMethod
import com.apollographql.apollo.compiler.IrOptions
import com.apollographql.apollo.compiler.JavaNullable
import com.apollographql.apollo.compiler.MANIFEST_OPERATION_OUTPUT
import com.apollographql.apollo.compiler.MANIFEST_PERSISTED_QUERY
import com.apollographql.apollo.compiler.MODELS_OPERATION_BASED
import com.apollographql.apollo.compiler.MODELS_OPERATION_BASED_WITH_INTERFACES
import com.apollographql.apollo.compiler.MODELS_RESPONSE_BASED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ abstract class ApolloRegisterOperationsTask: DefaultTask() {
}
} else {
logger.warn("Apollo: registering operations without a listId is deprecated")
@Suppress("DEPRECATION")
check(operationManifestFormat.get() == MANIFEST_OPERATION_OUTPUT) {
"""Apollo: registering legacy operations requires operationManifestFormat = "$MANIFEST_OPERATION_OUTPUT":
|apollo {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ abstract class DefaultApolloExtension(
project.tasks.register(ModelNames.downloadApolloSchema(), ApolloDownloadSchemaTask::class.java) { task ->
task.group = TASK_GROUP
task.projectRootDir = project.rootDir.absolutePath
task.doLast {
it.logger.lifecycle("Apollo: using './gradlew downloadApolloSchema' is deprecated. Please use the Apollo Kotlin cli for one-time downloads or the introspection {} block for Gradle downloads. See https://go.apollo.dev/ak-download-schema.")
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ private fun DefaultService.resolveOperationManifest(): Pair<String, File?> {
var format = operationManifestFormat.orNull
if (format == null) {
if (generateOperationOutput.orElse(false).get()) {
println("Apollo: using 'generateOperationOutput' is deprecated, please use 'operationManifestFormat.set(\"$MANIFEST_PERSISTED_QUERY\")' instead")
format = MANIFEST_OPERATION_OUTPUT
}
} else {
when (format) {
MANIFEST_NONE,
MANIFEST_OPERATION_OUTPUT,
MANIFEST_PERSISTED_QUERY,
-> Unit
MANIFEST_OPERATION_OUTPUT -> {
println("Apollo: using '$MANIFEST_OPERATION_OUTPUT' is deprecated, please use '$MANIFEST_PERSISTED_QUERY' instead")
}

else -> {
error("Apollo: unknown operation manifest format: $format")
Expand Down

0 comments on commit 3af9b79

Please sign in to comment.