From cd71e700db2a5b58be68687a9b7abf0cd7eca8b2 Mon Sep 17 00:00:00 2001 From: BoD Date: Fri, 4 Oct 2024 11:16:37 +0200 Subject: [PATCH] Avoid bidirectional = true --- .../feature1/build.gradle.kts | 22 ++++--------------- .../feature2/build.gradle.kts | 22 ++++--------------- .../graphqlSchema/build.gradle.kts | 16 ++++++++++++++ .../graphqlShared/build.gradle.kts | 20 ++++++++++------- 4 files changed, 36 insertions(+), 44 deletions(-) diff --git a/multi-modules-and-services/feature1/build.gradle.kts b/multi-modules-and-services/feature1/build.gradle.kts index 41a97d5..ef3f815 100644 --- a/multi-modules-and-services/feature1/build.gradle.kts +++ b/multi-modules-and-services/feature1/build.gradle.kts @@ -15,29 +15,15 @@ apollo { srcDir("src/main/graphql/servicea") packageName.set("com.example.servicea") - /* - * Depend on the schema and fragments from service "service-a" in module "graphqlShared". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling - * upstream modules to only generate the used types. - * - * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types - */ - dependsOn(project(":graphqlShared"), bidirectional = true) + // Depend on the schema and fragments from service "service-a" in module "graphqlShared". + dependsOn(project(":graphqlShared")) } service("service-b") { srcDir("src/main/graphql/serviceb") packageName.set("com.example.serviceb") - /* - * Depend on the schema and fragments from service "service-b" in module "graphqlShared". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling - * upstream modules to only generate the used types. - * - * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types - */ - dependsOn(project(":graphqlShared"), bidirectional = true) + // Depend on the schema and fragments from service "service-b" in module "graphqlShared". + dependsOn(project(":graphqlShared")) } } diff --git a/multi-modules-and-services/feature2/build.gradle.kts b/multi-modules-and-services/feature2/build.gradle.kts index 41a97d5..ef3f815 100644 --- a/multi-modules-and-services/feature2/build.gradle.kts +++ b/multi-modules-and-services/feature2/build.gradle.kts @@ -15,29 +15,15 @@ apollo { srcDir("src/main/graphql/servicea") packageName.set("com.example.servicea") - /* - * Depend on the schema and fragments from service "service-a" in module "graphqlShared". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling - * upstream modules to only generate the used types. - * - * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types - */ - dependsOn(project(":graphqlShared"), bidirectional = true) + // Depend on the schema and fragments from service "service-a" in module "graphqlShared". + dependsOn(project(":graphqlShared")) } service("service-b") { srcDir("src/main/graphql/serviceb") packageName.set("com.example.serviceb") - /* - * Depend on the schema and fragments from service "service-b" in module "graphqlShared". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling - * upstream modules to only generate the used types. - * - * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types - */ - dependsOn(project(":graphqlShared"), bidirectional = true) + // Depend on the schema and fragments from service "service-b" in module "graphqlShared". + dependsOn(project(":graphqlShared")) } } diff --git a/multi-modules-and-services/graphqlSchema/build.gradle.kts b/multi-modules-and-services/graphqlSchema/build.gradle.kts index 6de653a..1bcd863 100644 --- a/multi-modules-and-services/graphqlSchema/build.gradle.kts +++ b/multi-modules-and-services/graphqlSchema/build.gradle.kts @@ -19,6 +19,14 @@ apollo { endpointUrl.set("https://schema-servicea.com") schemaFile.set(file("src/main/graphql/servicea/schema.graphqls")) } + + /* + * Enable the bidirectional dependency which allows to reduce the size of the generated code by telling + * upstream modules to only generate the used types. + * + * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types + */ + isADependencyOf(project(":graphqlShared")) } service("service-b") { @@ -31,5 +39,13 @@ apollo { endpointUrl.set("https://schema-serviceb.com") schemaFile.set(file("src/main/graphql/serviceb/schema.graphqls")) } + + /* + * Enable the bidirectional dependency which allows to reduce the size of the generated code by telling + * upstream modules to only generate the used types. + * + * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types + */ + isADependencyOf(project(":graphqlShared")) } } diff --git a/multi-modules-and-services/graphqlShared/build.gradle.kts b/multi-modules-and-services/graphqlShared/build.gradle.kts index c196934..89bf40e 100644 --- a/multi-modules-and-services/graphqlShared/build.gradle.kts +++ b/multi-modules-and-services/graphqlShared/build.gradle.kts @@ -15,29 +15,33 @@ apollo { srcDir("src/main/graphql/servicea") packageName.set("com.example.servicea") + // Depend on the schema from service "service-a" in module "graphqlSchema". + dependsOn(project(":graphqlSchema")) + /* - * Depend on the schema from service "service-a" in module "graphqlSchema". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling + * Enable the bidirectional dependencies which allow to reduce the size of the generated code by telling * upstream modules to only generate the used types. * * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types */ - dependsOn(project(":graphqlSchema"), bidirectional = true) + isADependencyOf(project(":feature1")) + isADependencyOf(project(":feature2")) } service("service-b") { srcDir("src/main/graphql/serviceb") packageName.set("com.example.serviceb") + // Depend on the schema from service "service-b" in module "graphqlSchema". + dependsOn(project(":graphqlSchema")) + /* - * Depend on the schema from service "service-b" in module "graphqlSchema". - * - * The `bidirectional` parameter allows to reduce the size of the generated code by telling + * Enable the bidirectional dependencies which allow to reduce the size of the generated code by telling * upstream modules to only generate the used types. * * See https://www.apollographql.com/docs/kotlin/advanced/multi-modules/#auto-detection-of-used-types */ - dependsOn(project(":graphqlSchema"), bidirectional = true) + isADependencyOf(project(":feature1")) + isADependencyOf(project(":feature2")) } }