From 2281418e90083673f8a31f4112ae4f654ee8a9f2 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 29 Jan 2024 01:48:22 +0100 Subject: [PATCH 1/6] Deprecate sourceFolder and schemaFile --- .../apollo3/gradle/api/Service.kt | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/api/Service.kt b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/api/Service.kt index c9134993014..3f0f3953908 100644 --- a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/api/Service.kt +++ b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/api/Service.kt @@ -49,10 +49,12 @@ interface Service { /** * Where to look for GraphQL sources. - * The plugin will look in "src/main/graphql/$sourceFolder" for Android/JVM projects and "src/commonMain/graphql/$sourceFolder" for multiplatform projects. + * The plugin searches "src/main/graphql/$sourceFolder" for Android/JVM projects and "src/commonMain/graphql/$sourceFolder" for multiplatform projects. * - * For more control, see also [srcDir] + * For more control, see [srcDir] */ + @Deprecated("Replace with srcDir(\"src/[main|commonMain]/graphql/\$sourceFolder\")") + @ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0) val sourceFolder: Property /** @@ -62,23 +64,34 @@ interface Service { * * @param directory the directory where the .graphql operation files are * [directory] is evaluated as in [Project.file](https://docs.gradle.org/current/javadoc/org/gradle/api/Project.html#file-java.lang.Object-) - * Valid value include path Strings, File and RegularFileProperty - * */ fun srcDir(directory: Any) /** - * A shorthand property that will be used if [schemaFiles] is empty + * The location of the schema file. + * + * Because clients may extend the schema with client extensions in separate files, this is deprecated + * in favor of [schemaFiles]. */ + @Deprecated("Replace with schemaFiles.from()") + @ApolloDeprecatedSince(ApolloDeprecatedSince.Version.v4_0_0) val schemaFile: RegularFileProperty /** - * The schema files as either a ".json" introspection schema or a ".sdl|.graphqls" SDL schema. You might come across schemas named "schema.graphql", - * these are SDL schemas most of the time that need to be renamed to "schema.graphqls" to be recognized properly. + * The schema files in either ".json" introspection schemas or ".sdl|.graphqls" SDL schemas. * - * The compiler accepts multiple schema files in order to add extensions to specify key fields and other schema extensions. + * Most of the time, [schemaFiles] contains a main schema and an optional separate file for client extensions. + * You may set any number of files and the compiler will merge them. The merge order is: + * - main schema file first (the main schema file is the file that contains the schema definition or the Query type) + * - lexicographic order of the filename for other schema files * - * By default, the plugin collects all "schema.[json|sdl|graphqls]" file in the source roots + * If not set or empty, the plugin collects all "schema.[json|sdl|graphqls]" files in the [srcDir] roots. + * + * Example: + * + * ```kotlin + * schemaFiles.from("src/main/graphql/schema.graphqls", "src/main/graphql/extra.graphqls") + * ``` */ val schemaFiles: ConfigurableFileCollection From 89734e33942f9a9d94d8e6625dbcc3ac25500020 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 29 Jan 2024 15:28:54 +0100 Subject: [PATCH 2/6] replace our own usages of sourceFolder and schemaFile --- benchmark/app/build.gradle.kts | 2 +- benchmark/microbenchmark/build.gradle.kts | 6 +++--- docs/source/advanced/multi-modules.mdx | 4 ++-- docs/source/advanced/plugin-configuration.mdx | 14 +++++++------- intellij-plugin/build.gradle.kts | 4 ++-- .../ApolloEndpointNotConfiguredInspection.kt | 2 +- .../inspection/EndpointNotConfigured.gradle.kts | 4 ++-- .../EndpointNotConfigured_after.gradle.kts | 8 ++++---- .../gradle/internal/DefaultApolloExtension.kt | 4 ++++ .../apollo3/gradle/internal/DefaultService.kt | 2 ++ .../apollo3/gradle/test/GradleToolingTests.kt | 2 +- .../apollo3/gradle/test/KotlinDSLTests.kt | 2 +- .../apollo3/gradle/test/SchemaResolutionTests.kt | 2 +- .../apollo3/gradle/test/ServiceTests.kt | 2 +- .../testProjects/androidVariants/build.gradle.kts | 2 +- .../configuration-cache/root/build.gradle.kts | 2 +- .../downloadIntrospection/build.gradle.kts | 2 +- .../kotlinJvmSourceSets/build.gradle.kts | 2 +- .../testProjects/lazy-schema-file/build.gradle.kts | 2 +- libraries/apollo-tooling/build.gradle.kts | 6 +++--- tests/defer/build.gradle.kts | 4 ++-- tests/java-client/build.gradle.kts | 2 +- tests/multipart/build.gradle.kts | 4 ++-- tests/no-runtime/build.gradle.kts | 2 +- tests/normalization-tests/build.gradle.kts | 4 ++-- tests/pagination/build.gradle.kts | 10 +++++----- tests/platform-api/build.gradle.kts | 2 +- tests/runtime/build.gradle.kts | 2 +- tests/websockets/build.gradle.kts | 2 +- 29 files changed, 56 insertions(+), 50 deletions(-) diff --git a/benchmark/app/build.gradle.kts b/benchmark/app/build.gradle.kts index 9fdbbab7026..79841d12156 100644 --- a/benchmark/app/build.gradle.kts +++ b/benchmark/app/build.gradle.kts @@ -90,6 +90,6 @@ apollo { //generateCompiledField.set(false) addTypename.set("always") srcDir(generateQueries) - schemaFile.set(file("src/main/graphql/api/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/api/schema.graphqls")) } } diff --git a/benchmark/microbenchmark/build.gradle.kts b/benchmark/microbenchmark/build.gradle.kts index 7859d07ee15..840feac0957 100644 --- a/benchmark/microbenchmark/build.gradle.kts +++ b/benchmark/microbenchmark/build.gradle.kts @@ -93,16 +93,16 @@ java { configure { service("benchmark") { - sourceFolder.set("benchmark") + srcDir("src/main/graphql/benchmark") packageName.set("com.apollographql.apollo3.benchmark") } service("calendar-response") { - sourceFolder.set("calendar") + srcDir("src/main/graphql/calendar") codegenModels.set("responseBased") packageName.set("com.apollographql.apollo3.calendar.response") } service("calendar-operation") { - sourceFolder.set("calendar") + srcDir("src/main/graphql/calendar") codegenModels.set("operationBased") packageName.set("com.apollographql.apollo3.calendar.operation") } diff --git a/docs/source/advanced/multi-modules.mdx b/docs/source/advanced/multi-modules.mdx index 0e1d7be4281..8ea39797eef 100644 --- a/docs/source/advanced/multi-modules.mdx +++ b/docs/source/advanced/multi-modules.mdx @@ -22,8 +22,8 @@ apollo { // enable generation of metadata for use by downstream modules generateApolloMetadata.set(true) - // If you need to specify the location of your schema - schemaFile.set(/*...*/) + // If you need to specify the location of your schema files + schemaFiles.from(/*...*/) // define options that must be shared between all modules using this schema mapScalar(/*...*/) diff --git a/docs/source/advanced/plugin-configuration.mdx b/docs/source/advanced/plugin-configuration.mdx index d6b770b4df9..5f5746acd6d 100644 --- a/docs/source/advanced/plugin-configuration.mdx +++ b/docs/source/advanced/plugin-configuration.mdx @@ -32,7 +32,7 @@ Specify the location of your schema file using the `schemaFile` property: ```kotlin apollo { service("service") { - schemaFile.set(file("shared/graphql/schema.graphqls")) + schemaFiles.from(file("shared/graphql/schema.graphqls")) } } ``` @@ -172,7 +172,7 @@ apollo { introspection { endpointUrl.set("https://your.domain/graphql/endpoint") // The path is interpreted relative to the current project here, no need to prepend 'app' - schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) } } } @@ -194,7 +194,7 @@ apollo { key.set(System.getenv("APOLLO_KEY")) graph.set(System.geten("APOLLO_GRAPH")) // The path is interpreted relative to the current project here, no need to prepend 'app' - schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) } } } @@ -252,9 +252,9 @@ apollo { excludes.add("**/*.graphqls") // explicitly set the schema - schemaFile.set("src/main/graphql/schema.graphqls") + schemaFiles.from("src/main/graphql/schema.graphqls") // you can also merge different files together - schemaFile.setFrom("shared/graphql/schema.graphqls", "shared/graphql/extra.graphqls") + schemaFiles.fromFrom("shared/graphql/schema.graphqls", "shared/graphql/extra.graphqls") // What codegen to use. One of "operationBased", "responseBased" codegenModels.set("operationBased") @@ -363,13 +363,13 @@ apollo { // configure introspection schema download introspection { endpointUrl.set("https://your.domain/graphql/endpoint") - schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) } // configure registry schema download registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.geten("APOLLO_GRAPH")) - schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) } // wire the generated models to the "test" source set diff --git a/intellij-plugin/build.gradle.kts b/intellij-plugin/build.gradle.kts index bc4d86669bb..d3af3d80531 100644 --- a/intellij-plugin/build.gradle.kts +++ b/intellij-plugin/build.gradle.kts @@ -231,10 +231,10 @@ fun isSnapshotBuild() = System.getenv("IJ_PLUGIN_SNAPSHOT").toBoolean() apollo { service("apolloDebug") { packageName.set("com.apollographql.apollo3.debug") - schemaFile.set(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) + schemaFiles.from(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) introspection { endpointUrl.set("http://localhost:12200/") - schemaFile.set(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) + schemaFiles.from(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) } } } diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt index 4a28000307f..1b5d01f4c08 100644 --- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt +++ b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt @@ -54,7 +54,7 @@ object AddIntrospectionBlockQuickFix : LocalQuickFix { introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } """.trimIndent() ) diff --git a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts index 337b56dc47f..60e9132dbbe 100644 --- a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts +++ b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts @@ -17,7 +17,7 @@ apollo { srcDir("src/main/graphql") introspection { endpointUrl.set("https://example.com/graphql") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } } @@ -29,7 +29,7 @@ apollo { registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.getenv("APOLLO_GRAPH")) - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } } } diff --git a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts index 5dff57f909d..3ad18fddd77 100644 --- a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts +++ b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts @@ -11,7 +11,7 @@ apollo { introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } } @@ -22,7 +22,7 @@ apollo { srcDir("src/main/graphql") introspection { endpointUrl.set("https://example.com/graphql") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } } @@ -34,12 +34,12 @@ apollo { registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.getenv("APOLLO_GRAPH")) - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } } } diff --git a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultApolloExtension.kt b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultApolloExtension.kt index 48d567db300..9d5b05f98ff 100644 --- a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultApolloExtension.kt +++ b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultApolloExtension.kt @@ -360,7 +360,11 @@ abstract class DefaultApolloExtension( services.add(service) if (service.graphqlSourceDirectorySet.isReallyEmpty) { + @Suppress("DEPRECATION") val sourceFolder = service.sourceFolder.getOrElse("") + if (sourceFolder.isNotEmpty()) { + project.logger.lifecycle("Apollo: using 'sourceFolder' is deprecated, please replace with 'srcDir(\"src/${project.mainSourceSet()}/graphql/$sourceFolder\")'") + } val dir = File(project.projectDir, "src/${project.mainSourceSet()}/graphql/$sourceFolder") service.graphqlSourceDirectorySet.srcDir(dir) diff --git a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultService.kt b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultService.kt index 1423ec540ef..e78ccaa0003 100644 --- a/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultService.kt +++ b/libraries/apollo-gradle-plugin-external/src/main/kotlin/com/apollographql/apollo3/gradle/internal/DefaultService.kt @@ -215,7 +215,9 @@ internal fun DefaultService.fallbackFiles(project: Project, block: (Configurable internal fun DefaultService.schemaFiles(project: Project): FileCollection { val fileCollection = project.files() + @Suppress("DEPRECATION") if (schemaFile.isPresent) { + project.logger.lifecycle("Apollo: using 'schemaFile.set()' is deprecated as additional schema files like 'extra.graphqls' might be required. Please use 'schemaFiles.from()' instead.") fileCollection.from(schemaFile) } else { fileCollection.from(schemaFiles) diff --git a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt index f9d4e1a1052..cc747726694 100644 --- a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt +++ b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt @@ -35,7 +35,7 @@ class GradleToolingTests { srcDir("src/main/graphql/starwars") introspection { endpointUrl.set("https://example.com") - schemaFile.set(file("schema.graphqls")) + schemaFiles.from(file("schema.graphqls")) headers.set(["header1": "value1"]) } } diff --git a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/KotlinDSLTests.kt b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/KotlinDSLTests.kt index fba53dd7b3c..cb46365e182 100644 --- a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/KotlinDSLTests.kt +++ b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/KotlinDSLTests.kt @@ -38,7 +38,7 @@ class KotlinDSLTests { useSemanticNaming.set(false) mapScalar("DateTime", "java.util.Date") srcDir("src/main/graphql/com/example") - schemaFile.set(file("src/main/graphql/com/example/schema.json")) + schemaFiles.from(file("src/main/graphql/com/example/schema.json")) packageName.set("com.starwars") excludes.set(listOf("*.gql")) } diff --git a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/SchemaResolutionTests.kt b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/SchemaResolutionTests.kt index 46e16f61e30..d485bebbbe5 100644 --- a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/SchemaResolutionTests.kt +++ b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/SchemaResolutionTests.kt @@ -52,7 +52,7 @@ class SchemaResolutionTests { apollo { service("api") { packageNamesFromFilePaths() - schemaFile.set(file("src/main/graphql/schema.sdl")) + schemaFiles.from(file("src/main/graphql/schema.sdl")) } } """.trimIndent() diff --git a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/ServiceTests.kt b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/ServiceTests.kt index 372f2378588..e3ee5c6f8f8 100644 --- a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/ServiceTests.kt +++ b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/ServiceTests.kt @@ -120,7 +120,7 @@ class ServiceTests { withSimpleProject(""" apollo { service("starwars") { - schemaFile.set(file("${schema.absolutePath}")) + schemaFiles.from(file("${schema.absolutePath}")) packageName.set("com.example") } } diff --git a/libraries/apollo-gradle-plugin/testProjects/androidVariants/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/androidVariants/build.gradle.kts index 87c79bfbb6d..eb8950b7707 100644 --- a/libraries/apollo-gradle-plugin/testProjects/androidVariants/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/androidVariants/build.gradle.kts @@ -37,7 +37,7 @@ java.toolchain { apollo { createAllAndroidVariantServices(".", "example") { // Here we set the same schema file for all variants - schemaFile.set(file("src/main/graphql/com/example/schema.sdl")) + schemaFiles.from(file("src/main/graphql/com/example/schema.sdl")) packageName.set("com.example") } } diff --git a/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts index e61057c8004..0e812b803a1 100644 --- a/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts @@ -11,7 +11,7 @@ apollo { introspection { this.endpointUrl.set("ENDPOINT") - this.schemaFile.set(file("schema.json")) + this.schemaFiles.from(file("schema.json")) } } } diff --git a/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts index 33f22ed3c93..9d3ac4092bb 100644 --- a/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts @@ -8,7 +8,7 @@ apollo { packageName.set("com.example") introspection { endpointUrl.set("http://localhost:8001/graphql") - schemaFile.set(file("schema.graphqls")) + schemaFiles.from(file("schema.graphqls")) } } } diff --git a/libraries/apollo-gradle-plugin/testProjects/kotlinJvmSourceSets/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/kotlinJvmSourceSets/build.gradle.kts index 0a18e752ac6..12572b909f7 100644 --- a/libraries/apollo-gradle-plugin/testProjects/kotlinJvmSourceSets/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/kotlinJvmSourceSets/build.gradle.kts @@ -11,6 +11,6 @@ dependencies { apollo { createAllKotlinSourceSetServices(".", "example") { packageNamesFromFilePaths() - schemaFile.set(file("src/main/graphql/com/example/schema.sdl")) + schemaFiles.from(file("src/main/graphql/com/example/schema.sdl")) } } diff --git a/libraries/apollo-gradle-plugin/testProjects/lazy-schema-file/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/lazy-schema-file/build.gradle.kts index a1f25e93aab..75e323c1f42 100644 --- a/libraries/apollo-gradle-plugin/testProjects/lazy-schema-file/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/lazy-schema-file/build.gradle.kts @@ -20,6 +20,6 @@ val installTask = tasks.register("generateSchema", GenerateSchemaTask::class.jav apollo { service("service") { packageName.set("com.example") - schemaFile.set(installTask.flatMap { it.outputFile }) + schemaFiles.from(installTask.flatMap { it.outputFile }) } } diff --git a/libraries/apollo-tooling/build.gradle.kts b/libraries/apollo-tooling/build.gradle.kts index 31c04ac02e7..b2e970a493a 100644 --- a/libraries/apollo-tooling/build.gradle.kts +++ b/libraries/apollo-tooling/build.gradle.kts @@ -30,14 +30,14 @@ apollo { // https://spec.graphql.org/draft/#sec-Schema-Introspection.Schema-Introspection-Schema service("graphql") { packageName.set("com.apollographql.apollo3.tooling.graphql") - sourceFolder.set("graphql") + srcDir("src/main/graphql/graphql") generateAsInternal.set(true) } // https://studio.apollographql.com/public/apollo-platform/variant/main/home service("platform-api-public") { packageName.set("com.apollographql.apollo3.tooling.platformapi.public") - sourceFolder.set("platform-api/public") + srcDir("src/main/graphql/platform-api/public") generateAsInternal.set(true) mapScalarToKotlinString("GraphQLDocument") registry { @@ -51,7 +51,7 @@ apollo { // https://studio-staging.apollographql.com/graph/engine/variant/prod/home service("platform-api-internal") { packageName.set("com.apollographql.apollo3.tooling.platformapi.internal") - sourceFolder.set("platform-api/internal") + srcDir("src/main/graphql/platform-api/internal") generateAsInternal.set(true) introspection { endpointUrl.set("https://graphql.api.apollographql.com/api/graphql") diff --git a/tests/defer/build.gradle.kts b/tests/defer/build.gradle.kts index 738dade5c8c..548aaccc7fb 100644 --- a/tests/defer/build.gradle.kts +++ b/tests/defer/build.gradle.kts @@ -49,12 +49,12 @@ fun configureApollo(generateKotlinModels: Boolean) { service("base-$extra") { packageName.set("defer") this.generateKotlinModels.set(generateKotlinModels) - sourceFolder.set("base") + srcDir("src/commonMain/graphql/base") configureConnection(generateKotlinModels) } service("supergraph-$extra") { packageName.set("supergraph") - sourceFolder.set("supergraph") + srcDir("src/commonMain/graphql/supergraph") this.addTypename.set("ifAbstract") this.generateKotlinModels.set(generateKotlinModels) configureConnection(generateKotlinModels) diff --git a/tests/java-client/build.gradle.kts b/tests/java-client/build.gradle.kts index c5e5331fc28..265f770efc8 100644 --- a/tests/java-client/build.gradle.kts +++ b/tests/java-client/build.gradle.kts @@ -16,7 +16,7 @@ dependencies { apollo { service("main") { - schemaFile.set(file("../sample-server/src/main/resources/schema.graphqls")) + schemaFiles.from(file("../sample-server/src/main/resources/schema.graphqls")) srcDir("src/main/graphql/main") packageName.set("javatest") generateModelBuilders.set(true) diff --git a/tests/multipart/build.gradle.kts b/tests/multipart/build.gradle.kts index 8fe3275ffe0..671dd0c4cd3 100644 --- a/tests/multipart/build.gradle.kts +++ b/tests/multipart/build.gradle.kts @@ -24,11 +24,11 @@ kotlin { apollo { service("mockserver") { - sourceFolder.set("mockserver") + srcDir("src/commonMain/graphql/mockserver") packageName.set("multipart") } service("router") { - sourceFolder.set("router") + srcDir("src/commonMain/graphql/router") packageName.set("router") } } diff --git a/tests/no-runtime/build.gradle.kts b/tests/no-runtime/build.gradle.kts index b6b0d8c3f77..9694dd538d5 100644 --- a/tests/no-runtime/build.gradle.kts +++ b/tests/no-runtime/build.gradle.kts @@ -17,6 +17,6 @@ dependencies { apollo { service("service") { packageName.set("com.example") - schemaFile.set(file("../sample-server/src/main/resources/schema.graphqls")) + schemaFiles.from(file("../sample-server/src/main/resources/schema.graphqls")) } } diff --git a/tests/normalization-tests/build.gradle.kts b/tests/normalization-tests/build.gradle.kts index 2d104e74e3d..a4ccc119fa7 100644 --- a/tests/normalization-tests/build.gradle.kts +++ b/tests/normalization-tests/build.gradle.kts @@ -16,11 +16,11 @@ dependencies { apollo { service("1") { - sourceFolder.set("1") + srcDir("src/main/graphql/1") packageName.set("com.example.one") } service("2") { - sourceFolder.set("2") + srcDir("src/main/graphql/2") packageName.set("com.example.two") } service("3") { diff --git a/tests/pagination/build.gradle.kts b/tests/pagination/build.gradle.kts index 5987e83ec58..dda684785c6 100644 --- a/tests/pagination/build.gradle.kts +++ b/tests/pagination/build.gradle.kts @@ -29,27 +29,27 @@ kotlin { apollo { service("embed") { packageName.set("embed") - sourceFolder.set("embed") + srcDir("src/commonMain/graphql/embed") } service("pagination.offsetBasedWithArray") { packageName.set("pagination.offsetBasedWithArray") - sourceFolder.set("pagination/offsetBasedWithArray") + srcDir("src/commonMain/graphql/pagination/offsetBasedWithArray") generateDataBuilders.set(true) } service("pagination.offsetBasedWithPage") { packageName.set("pagination.offsetBasedWithPage") - sourceFolder.set("pagination/offsetBasedWithPage") + srcDir("src/commonMain/graphql/pagination/offsetBasedWithPage") generateDataBuilders.set(true) } service("pagination.cursorBased") { packageName.set("pagination.cursorBased") - sourceFolder.set("pagination/cursorBased") + srcDir("src/commonMain/graphql/pagination/cursorBased") generateDataBuilders.set(true) } service("pagination.connection") { packageName.set("pagination.connection") - sourceFolder.set("pagination/connection") + srcDir("src/commonMain/graphql/pagination/connection") generateDataBuilders.set(true) } } diff --git a/tests/platform-api/build.gradle.kts b/tests/platform-api/build.gradle.kts index 01a206d46ec..27548acf9f0 100644 --- a/tests/platform-api/build.gradle.kts +++ b/tests/platform-api/build.gradle.kts @@ -26,7 +26,7 @@ apollo { key.set(apiKey) graph.set("Apollo-Kotlin-CI-tests") graphVariant.set("current") - schemaFile.set(file("src/main/graphql/schema.graphqls")) + schemaFiles.from(file("src/main/graphql/schema.graphqls")) } operationManifestFormat.set("persistedQueryManifest") diff --git a/tests/runtime/build.gradle.kts b/tests/runtime/build.gradle.kts index 9821ef5d7a8..97055513533 100644 --- a/tests/runtime/build.gradle.kts +++ b/tests/runtime/build.gradle.kts @@ -18,6 +18,6 @@ apollo { service("service") { generateDataBuilders.set(true) packageName.set("com.example") - schemaFile.set(file("../sample-server/src/main/resources/schema.graphqls")) + schemaFiles.from(file("../sample-server/src/main/resources/schema.graphqls")) } } diff --git a/tests/websockets/build.gradle.kts b/tests/websockets/build.gradle.kts index 08c4a89eb3c..bb7b5c6b16d 100644 --- a/tests/websockets/build.gradle.kts +++ b/tests/websockets/build.gradle.kts @@ -35,7 +35,7 @@ apollo { }?.forEach { service(it.name) { if (it.name == "sample-server") { - schemaFile.set(file("../sample-server/src/main/resources/schema.graphqls")) + schemaFiles.from(file("../sample-server/src/main/resources/schema.graphqls")) } srcDir(it) packageName.set(it.name.replace("-", ".")) From 9b7b2d94d92a96d2b03c6989ba419053623a481e Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 29 Jan 2024 15:33:56 +0100 Subject: [PATCH 3/6] fix bad copy/paste --- .../com/apollographql/apollo3/gradle/test/GradleToolingTests.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt index cc747726694..f9d4e1a1052 100644 --- a/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt +++ b/libraries/apollo-gradle-plugin/src/test-java11/kotlin/com/apollographql/apollo3/gradle/test/GradleToolingTests.kt @@ -35,7 +35,7 @@ class GradleToolingTests { srcDir("src/main/graphql/starwars") introspection { endpointUrl.set("https://example.com") - schemaFiles.from(file("schema.graphqls")) + schemaFile.set(file("schema.graphqls")) headers.set(["header1": "value1"]) } } From 6dfaaa505c3da4b1c74c2c826c74d7bba25d8de5 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 29 Jan 2024 15:38:47 +0100 Subject: [PATCH 4/6] fix bad search & replace --- docs/source/advanced/plugin-configuration.mdx | 8 ++++---- intellij-plugin/build.gradle.kts | 2 +- .../inspection/ApolloEndpointNotConfiguredInspection.kt | 2 +- .../testData/inspection/EndpointNotConfigured.gradle.kts | 4 ++-- .../inspection/EndpointNotConfigured_after.gradle.kts | 8 ++++---- .../configuration-cache/root/build.gradle.kts | 2 +- .../testProjects/downloadIntrospection/build.gradle.kts | 2 +- tests/platform-api/build.gradle.kts | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/source/advanced/plugin-configuration.mdx b/docs/source/advanced/plugin-configuration.mdx index 5f5746acd6d..fc7c108e5f7 100644 --- a/docs/source/advanced/plugin-configuration.mdx +++ b/docs/source/advanced/plugin-configuration.mdx @@ -172,7 +172,7 @@ apollo { introspection { endpointUrl.set("https://your.domain/graphql/endpoint") // The path is interpreted relative to the current project here, no need to prepend 'app' - schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) + schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) } } } @@ -194,7 +194,7 @@ apollo { key.set(System.getenv("APOLLO_KEY")) graph.set(System.geten("APOLLO_GRAPH")) // The path is interpreted relative to the current project here, no need to prepend 'app' - schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) + schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) } } } @@ -363,13 +363,13 @@ apollo { // configure introspection schema download introspection { endpointUrl.set("https://your.domain/graphql/endpoint") - schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) + schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) } // configure registry schema download registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.geten("APOLLO_GRAPH")) - schemaFiles.from(file("src/main/graphql/com/example/schema.graphqls")) + schemaFile.set(file("src/main/graphql/com/example/schema.graphqls")) } // wire the generated models to the "test" source set diff --git a/intellij-plugin/build.gradle.kts b/intellij-plugin/build.gradle.kts index d3af3d80531..666f938ff01 100644 --- a/intellij-plugin/build.gradle.kts +++ b/intellij-plugin/build.gradle.kts @@ -234,7 +234,7 @@ apollo { schemaFiles.from(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) introspection { endpointUrl.set("http://localhost:12200/") - schemaFiles.from(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) + schemaFile.set(file("../libraries/apollo-debug-server/src/androidMain/resources/schema.graphqls")) } } } diff --git a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt index 1b5d01f4c08..4a28000307f 100644 --- a/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt +++ b/intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/inspection/ApolloEndpointNotConfiguredInspection.kt @@ -54,7 +54,7 @@ object AddIntrospectionBlockQuickFix : LocalQuickFix { introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } """.trimIndent() ) diff --git a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts index 60e9132dbbe..337b56dc47f 100644 --- a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts +++ b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured.gradle.kts @@ -17,7 +17,7 @@ apollo { srcDir("src/main/graphql") introspection { endpointUrl.set("https://example.com/graphql") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } } @@ -29,7 +29,7 @@ apollo { registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.getenv("APOLLO_GRAPH")) - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } } } diff --git a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts index 3ad18fddd77..5dff57f909d 100644 --- a/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts +++ b/intellij-plugin/src/test/testData/inspection/EndpointNotConfigured_after.gradle.kts @@ -11,7 +11,7 @@ apollo { introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } } @@ -22,7 +22,7 @@ apollo { srcDir("src/main/graphql") introspection { endpointUrl.set("https://example.com/graphql") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } } @@ -34,12 +34,12 @@ apollo { registry { key.set(System.getenv("APOLLO_KEY")) graph.set(System.getenv("APOLLO_GRAPH")) - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } introspection { endpointUrl.set("https://example.com/graphql") headers.put("api-key", "1234567890abcdef") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } } } diff --git a/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts index 0e812b803a1..16c3435f68c 100644 --- a/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/configuration-cache/root/build.gradle.kts @@ -11,7 +11,7 @@ apollo { introspection { this.endpointUrl.set("ENDPOINT") - this.schemaFiles.from(file("schema.json")) + schemaFile.set(file("schema.json")) } } } diff --git a/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts b/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts index 9d3ac4092bb..33f22ed3c93 100644 --- a/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts +++ b/libraries/apollo-gradle-plugin/testProjects/downloadIntrospection/build.gradle.kts @@ -8,7 +8,7 @@ apollo { packageName.set("com.example") introspection { endpointUrl.set("http://localhost:8001/graphql") - schemaFiles.from(file("schema.graphqls")) + schemaFile.set(file("schema.graphqls")) } } } diff --git a/tests/platform-api/build.gradle.kts b/tests/platform-api/build.gradle.kts index 27548acf9f0..01a206d46ec 100644 --- a/tests/platform-api/build.gradle.kts +++ b/tests/platform-api/build.gradle.kts @@ -26,7 +26,7 @@ apollo { key.set(apiKey) graph.set("Apollo-Kotlin-CI-tests") graphVariant.set("current") - schemaFiles.from(file("src/main/graphql/schema.graphqls")) + schemaFile.set(file("src/main/graphql/schema.graphqls")) } operationManifestFormat.set("persistedQueryManifest") From d4e99440524f5e5388036b00216d54eee87cefba Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Mon, 29 Jan 2024 15:49:32 +0100 Subject: [PATCH 5/6] slightly tweak the docs --- docs/source/advanced/plugin-configuration.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/advanced/plugin-configuration.mdx b/docs/source/advanced/plugin-configuration.mdx index fc7c108e5f7..7321f105d92 100644 --- a/docs/source/advanced/plugin-configuration.mdx +++ b/docs/source/advanced/plugin-configuration.mdx @@ -251,9 +251,9 @@ apollo { // Operation files to exclude. excludes.add("**/*.graphqls") - // explicitly set the schema + // Explicitly set the schema schemaFiles.from("src/main/graphql/schema.graphqls") - // you can also merge different files together + // Extend your schema locally with type extensions schemaFiles.fromFrom("shared/graphql/schema.graphqls", "shared/graphql/extra.graphqls") // What codegen to use. One of "operationBased", "responseBased" From 5915801721b7b937ca0bbc09cc725456b2c8ff23 Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Tue, 30 Jan 2024 11:03:17 +0100 Subject: [PATCH 6/6] fromFrom -> from --- docs/source/advanced/plugin-configuration.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/advanced/plugin-configuration.mdx b/docs/source/advanced/plugin-configuration.mdx index 7321f105d92..77c25df91f1 100644 --- a/docs/source/advanced/plugin-configuration.mdx +++ b/docs/source/advanced/plugin-configuration.mdx @@ -254,7 +254,7 @@ apollo { // Explicitly set the schema schemaFiles.from("src/main/graphql/schema.graphqls") // Extend your schema locally with type extensions - schemaFiles.fromFrom("shared/graphql/schema.graphqls", "shared/graphql/extra.graphqls") + schemaFiles.from("shared/graphql/schema.graphqls", "shared/graphql/extra.graphqls") // What codegen to use. One of "operationBased", "responseBased" codegenModels.set("operationBased")