Hi, I am trying to perform a query with fetchPolic...
# apollo-kotlin
j
Hi, I am trying to perform a query with fetchPolicy but in version 3.2.1 the method does not exist, in the documentation it is but when I do it in an example the method does not exist, could you please help me Client
Copy code
ApolloClient.Builder()
    .serverUrl(BuildConfig.HOST)
    .okHttpClient(okHttpClient.build())
    .autoPersistedQueries(
        httpMethodForHashedQueries = HttpMethod.Get,
        httpMethodForDocumentQueries = HttpMethod.Get,
    )
    .normalizedCache(cacheFactory)
    .addInterceptor(SessionInterceptor(context))
    .addInterceptor(LanguageInterceptor())
    .build()
Query
Copy code
val queryResult = query(query).fetchPolicy(CacheFirst).execute()
Methods normalizedCache and fetchPolicy not found in 3.2.1
m
Hi 😊. Most likely you'll need to add
apollo-normalized-cache
to your dependencies
j
hi @mbonnin these are the dependecias have
Copy code
const val graphQLRuntime =
    "com.apollographql.apollo3:apollo-runtime:${Versions.graphQL}"
const val graphQLApi =
    "com.apollographql.apollo3:apollo-api:${Versions.graphQL}"
const val memoryCache =
    "com.apollographql.apollo3:apollo-normalized-cache-sqlite:${Versions.graphQL}"
Copy code
Versions.graphQL = 3.2.1
s
normalized-cache-sqlite and normalized-cache are two different dependencies afaik. As long as you don’t have something that transitively depends on the normalized-cache artifact, you will have to bring in that dependency in yourself.
And looking at the build file for normalized-cache and normalized-cache-sqlite, they both depend only on normalized-cache-api, so no, you probably don’t have normalized-cache on your build. Try adjusting the above code snippet you sent before to something like this:
Copy code
const val graphQLRuntime = "com.apollographql.apollo3:apollo-runtime:${Versions.graphQL}"
const val graphQLApi = "com.apollographql.apollo3:apollo-api:${Versions.graphQL}"
const val normalizedCacheSqlite = "com.apollographql.apollo3:apollo-normalized-cache-sqlite:${Versions.graphQL}"
const val normalizedCache = "com.apollographql.apollo3:apollo-normalized-cache:${Versions.graphQL}"
and see if your IDE is happy after syncing gradle.
j
thanks @Stylianos Gakis @mbonnin
🙌 2