agrosner
09/26/2022, 6:44 PMwatch method. We have some calls that do not want to use a cache at all, so we use FetchPolicy.NetworkOnly . When watch executes, we always receive two network calls!
we have traced it down to this line in `watch`:
copy().fetchPolicyInterceptor(refetchPolicyInterceptor)
.watch(response?.data) { _, _ ->
this line. since our request context has no cache interceptors, when the call is executed at this point, it always hits the network.mbonnin
09/26/2022, 8:10 PM.watch() together with FetchPolicy.NetworkOnly ?mbonnin
09/26/2022, 8:10 PMapolloClient.query(MyQuery()).fetchPolicy(FetchPolicy.NetworkOnly).watch()
?mbonnin
09/26/2022, 8:49 PMagrosner
09/26/2022, 8:50 PMmbonnin
09/26/2022, 8:51 PMapolloClient.query(MyQuery()).fetchPolicy(FetchPolicy.NetworkOnly).watch()agrosner
09/26/2022, 8:51 PMmbonnin
09/26/2022, 8:52 PM.watch() for a network only request. Any reason your not just calling .execute() ?agrosner
09/27/2022, 1:13 PMprivate fun <D : Query.Data> fullQueryChain(
query: Query<D>,
params: ApolloQueryExecutor.Params,
fetchPolicy: ApolloQueryExecutor.FetchPolicy
) = apolloClient.query(query)
.fetchPolicy(fetchPolicy.toApolloFetchPolicy())
.httpFetchPolicy(fetchPolicy.toHttpFetchPolicy())
.httpExpireTimeout(params.httpExpirationInMillis)
.watch(fetchThrows = true)
which allows different params to specify their own fetch policy. some requests may not want cache, while some do. so i figured using same place to determine that. it was unexpected behavior to hit a network call twice on watch.agrosner
09/27/2022, 1:14 PMtoFlow() for the specified request instead of watchmbonnin
09/27/2022, 1:24 PM.watch() behaviour more. AFAIK, something like apolloClient.query(MyQuery()).fetchPolicy(FetchPolicy.NetworkOnly).watch() should only reach to the network once (because the refectPolicy defaults to CacheOnly ) but maybe there's more to it