From 674da5ed5ed0d7c646db330c90960d91e0439ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Salcedo=20Garc=C3=ADa?= Date: Thu, 4 Jan 2024 11:49:11 +0100 Subject: [PATCH] feat: migrate to Apollo4 --- .../data/KatanaMultiplatformDataRemotePlugin.kt | 16 +++++++++++----- common/user/data/build.gradle.kts | 4 ---- .../remote/src/commonMain/graphql/extra.graphqls | 4 ++++ features/account/data/build.gradle.kts | 4 ---- features/explore/data/build.gradle.kts | 4 ---- features/lists/data/build.gradle.kts | 4 ---- features/social/data/build.gradle.kts | 4 ---- gradle/libs.versions.toml | 2 +- 8 files changed, 16 insertions(+), 26 deletions(-) create mode 100644 core/remote/src/commonMain/graphql/extra.graphqls diff --git a/build-logic/katana-convention/src/main/kotlin/dev/alvr/katana/buildlogic/mp/mobile/data/KatanaMultiplatformDataRemotePlugin.kt b/build-logic/katana-convention/src/main/kotlin/dev/alvr/katana/buildlogic/mp/mobile/data/KatanaMultiplatformDataRemotePlugin.kt index f7484ebfd..5fd739119 100644 --- a/build-logic/katana-convention/src/main/kotlin/dev/alvr/katana/buildlogic/mp/mobile/data/KatanaMultiplatformDataRemotePlugin.kt +++ b/build-logic/katana-convention/src/main/kotlin/dev/alvr/katana/buildlogic/mp/mobile/data/KatanaMultiplatformDataRemotePlugin.kt @@ -61,23 +61,29 @@ internal class KatanaMultiplatformDataRemotePlugin : Plugin { private fun ApolloExtension.configureApollo() { service("anilist") { generateAsInternal = true - generateDataBuilders = true packageName = fullPackageName + generateMethods = listOf("equalsHashCode") - if (fullPackageName.contains(BASE_PACKAGE)) { - alwaysGenerateTypesMatching = listOf("Query", "User") + if (path == CORE_PROJECT) { generateApolloMetadata = true generateAsInternal = false + generateDataBuilders = true + schemaFiles.from( + file("src/commonMain/graphql/schema.graphqls"), + file("src/commonMain/graphql/extra.graphqls"), + ) introspection { endpointUrl = "https://graphql.anilist.co" - schemaFile = project.file("src/commonMain/graphql/schema.graphqls") + schemaFiles.from(file("src/commonMain/graphql/schema.graphqls")) } + } else { + dependsOn(project(CORE_PROJECT)) } } } private companion object { - const val BASE_PACKAGE = ".remote" + const val CORE_PROJECT = ":core:remote" } } diff --git a/common/user/data/build.gradle.kts b/common/user/data/build.gradle.kts index 8c1e3c3aa..6f63c99ff 100644 --- a/common/user/data/build.gradle.kts +++ b/common/user/data/build.gradle.kts @@ -2,10 +2,6 @@ plugins { id("katana.multiplatform.data.remote") } -dependencies { - apolloMetadata(projects.core.remote) -} - katanaMultiplatform { commonMainDependencies { implementation(projects.core.common) diff --git a/core/remote/src/commonMain/graphql/extra.graphqls b/core/remote/src/commonMain/graphql/extra.graphqls new file mode 100644 index 000000000..13685db55 --- /dev/null +++ b/core/remote/src/commonMain/graphql/extra.graphqls @@ -0,0 +1,4 @@ +extend schema @link( + url: "https://specs.apollo.dev/kotlin_labs/v0.2", + import: ["@nonnull"] +) diff --git a/features/account/data/build.gradle.kts b/features/account/data/build.gradle.kts index 93e1fdd9c..ca626a75f 100644 --- a/features/account/data/build.gradle.kts +++ b/features/account/data/build.gradle.kts @@ -2,10 +2,6 @@ plugins { id("katana.multiplatform.data.remote") } -dependencies { - apolloMetadata(projects.core.remote) -} - katanaMultiplatform { commonMainDependencies { implementation(projects.core.remote) diff --git a/features/explore/data/build.gradle.kts b/features/explore/data/build.gradle.kts index 67d16b735..f9804cbde 100644 --- a/features/explore/data/build.gradle.kts +++ b/features/explore/data/build.gradle.kts @@ -2,10 +2,6 @@ plugins { id("katana.multiplatform.data.remote") } -dependencies { - apolloMetadata(projects.core.remote) -} - katanaMultiplatform { commonMainDependencies { implementation(projects.core.remote) diff --git a/features/lists/data/build.gradle.kts b/features/lists/data/build.gradle.kts index d93813613..e16797cf1 100644 --- a/features/lists/data/build.gradle.kts +++ b/features/lists/data/build.gradle.kts @@ -2,10 +2,6 @@ plugins { id("katana.multiplatform.data.remote") } -dependencies { - apolloMetadata(projects.core.remote) -} - katanaMultiplatform { commonMainDependencies { implementation(projects.common.user.domain) diff --git a/features/social/data/build.gradle.kts b/features/social/data/build.gradle.kts index 881f2c4b3..dd81aed27 100644 --- a/features/social/data/build.gradle.kts +++ b/features/social/data/build.gradle.kts @@ -2,10 +2,6 @@ plugins { id("katana.multiplatform.data.remote") } -dependencies { - apolloMetadata(projects.core.remote) -} - katanaMultiplatform { commonMainDependencies { implementation(projects.core.remote) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b1b5d1634..8c1b7a898 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,7 +3,7 @@ android = "8.3.2" androidx-activity = "1.9.0" androidx-lifecycle = "2.7.0" androidx-splashscreen = "1.0.1" -apollo = "3.8.3" +apollo = "4.0.0-beta.5" arrow = "1.2.4" buildconfig = "5.3.5" complete-kotlin = "1.1.0"