Configuring the fetch policy when Migrating to Apollo3 on Android

The docs show this snippet for setting Fetch Policy


// Replace
val response = apolloClient.query(query)
                      .toBuilder()
                      .responseFetcher(ApolloResponseFetchers.CACHE_FIRST)
                      .build()
                      .await()

// With
val request = ApolloRequest(query).withFetchPolicy(CacheFirst)
val response = apolloClient.query(request)

However when I try this code snippet in Android Studio there is no function called withFetchPolicy()

my gradle resembles this

api 'com.apollographql.apollo3:apollo-runtime:3.0.0-alpha03'
api 'com.apollographql.apollo3:apollo-api:3.0.0-alpha03'

with plugin this

plugins {
    id "com.android.library"
    id "kotlin-android"
    id "kotlin-kapt"
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.20'
    id 'dagger.hilt.android.plugin'
    id 'com.apollographql.apollo3' version '3.0.0-alpha03'
}

where have I gone wrong?

Hi :wave:

Pretty sure we talked on the Kotlin slack but for the record, withFetchPolicy is an extension function defined in the apollo-normalized-cache artifact. You’ll need to add this to your gradle scripts:

dependencies {
  implementation 'com.apollographql.apollo3:apollo-normalized-cache:3.0.0-alpha03'
}