# Best Practice for Handling Build Type-Specific Schema Endpoints in Android Multi-Module Setup

**URL:** <https://community.apollographql.com/t/best-practice-for-handling-build-type-specific-schema-endpoints-in-android-multi-module-setup/9524>\
**Category:** Client SDKs\
**Tags:** mobile, kotlin\
**Created:** [October 23, 2025, 7:16am UTC](https://community.apollographql.com/t/best-practice-for-handling-build-type-specific-schema-endpoints-in-android-multi-module-setup/9524 "2025-10-23T07:16:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lana\_Mozharovska](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/lana_mozharovska/32/6225_2.png) [@Lana\_Mozharovska](https://community.apollographql.com/u/Lana_Mozharovska)\
**Post date:** [October 23, 2025, 7:16am UTC](https://community.apollographql.com/t/best-practice-for-handling-build-type-specific-schema-endpoints-in-android-multi-module-setup/9524/1 "2025-10-23T07:16:25Z")

</div>

Hi Apollo Community,

I’m working on a multi-module Android project and trying to figure out the best way to handle schema downloads based on our app’s build types.

**Our Setup:**

- `:app` module: Defines `buildTypes` (`debug`, `stage`, `release`) and uses `buildConfigField` to set the corresponding `BASE_URL` for each.

- `:graphql` module: A separate Android library module responsible for Apollo code generation. It contains all our shared `.graphql` query/fragment files in `src/main/graphql/com/example`. It also needs to download the schema using introspection.

**The Goal:**

I want the `:graphql` module to download the schema from a **different endpoint URL** depending on the build type being compiled in the `:app` module (e.g., use `http://dev/graphql` for `debug`, `https://stage/graphql` for `stage`/`release`). I also have separate schema files for each environment (`src/debug/graphql/.../schema.graphqls`, `src/stage/graphql/.../schema.graphqls`, etc.).

**The Problem:**

The `:graphql` library module doesn’t have direct access to the `buildTypes` defined in the `:app` module, so I can’t easily read the `BASE_URL` or know which build type is active during the Apollo code generation phase.

**My Attempt (which failed):**

I tried defining separate Apollo `service` blocks in my `:graphql/build.gradle.kts` like this:

Kotlin

```auto
// In :graphql/build.gradle.kts
apollo {
    service("debug") {
        
        srcDir("src/debug/graphql/com/example")
        packageName.set("com.example.graphql")
        introspection {
            endpointUrl.set("http://dev/graphql")
            schemaFile.set(file("src/debug/graphql/com/example/schema.graphqls"))
        }
        outputDirConnection { connectToAndroidSourceSet("debug") }
    }
    service("stage") {
        srcDir("src/stage/graphql/com/example") 
        // ... similar config ...
    }
    service("release") {
        srcDir("src/release/graphql/com/example")
        // ... similar config ...
    }
}

```

This failed because my actual query files (`.graphql`) are located in the common `src/main/graphql/com/example` directory, not in the build-type specific directories. The configuration couldn’t find the queries.

**The Question:**

What is the recommended approach using the Apollo 4.x Gradle plugin to achieve this? How can I configure the schema download within my `:graphql` library module based on the `:app` module’s build type, while still using the shared query files from `src/main/graphql`?

Thanks for any guidance!
