Skip to content

Commit c2a1286

Browse files
committed
Add CacheOptions
1 parent 38e4576 commit c2a1286

12 files changed

Lines changed: 155 additions & 75 deletions

File tree

normalized-cache/api/normalized-cache.api

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ public final class com/apollographql/cache/normalized/CacheMissLoggingIntercepto
127127
public fun intercept (Lcom/apollographql/apollo/api/ApolloRequest;Lcom/apollographql/apollo/interceptor/ApolloInterceptorChain;)Lkotlinx/coroutines/flow/Flow;
128128
}
129129

130+
public abstract interface class com/apollographql/cache/normalized/CacheOptions {
131+
public abstract fun allowCachedErrors (Z)V
132+
public abstract fun allowCachedPartialResults (Z)V
133+
public abstract fun noCache (Z)V
134+
public abstract fun onlyIfCached (Z)V
135+
public abstract fun reload (Z)V
136+
}
137+
130138
public final class com/apollographql/cache/normalized/ErrorExtensionsKt {
131139
public static final fun getCacheMissException (Lcom/apollographql/apollo/api/Error;)Lcom/apollographql/apollo/exception/CacheMissException;
132140
}
@@ -147,7 +155,7 @@ public final class com/apollographql/cache/normalized/FetchPolicyInterceptors {
147155
public static final fun getCacheAndNetworkInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
148156
public static final fun getCacheFirstInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
149157
public static final fun getCacheOnlyInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
150-
public static final fun getDonkeyInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
158+
public static final fun getDefaultFetchPolicyInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
151159
public static final fun getNetworkFirstInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
152160
public static final fun getNetworkOnlyInterceptor ()Lcom/apollographql/apollo/interceptor/ApolloInterceptor;
153161
}
@@ -215,8 +223,10 @@ public final class com/apollographql/cache/normalized/NormalizedCache {
215223
public static final fun onlyIfCached (Lcom/apollographql/apollo/api/MutableExecutionOptions;Z)Ljava/lang/Object;
216224
public static final fun optimisticUpdates (Lcom/apollographql/apollo/ApolloCall;Lcom/apollographql/apollo/api/Mutation$Data;)Lcom/apollographql/apollo/ApolloCall;
217225
public static final fun optimisticUpdates (Lcom/apollographql/apollo/api/ApolloRequest$Builder;Lcom/apollographql/apollo/api/Mutation$Data;)Lcom/apollographql/apollo/api/ApolloRequest$Builder;
226+
public static final fun refetchCacheOptions (Lcom/apollographql/apollo/api/MutableExecutionOptions;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
218227
public static final fun refetchPolicy (Lcom/apollographql/apollo/api/MutableExecutionOptions;Lcom/apollographql/cache/normalized/FetchPolicy;)Ljava/lang/Object;
219228
public static final fun refetchPolicyInterceptor (Lcom/apollographql/apollo/api/MutableExecutionOptions;Lcom/apollographql/apollo/interceptor/ApolloInterceptor;)Ljava/lang/Object;
229+
public static final fun reload (Lcom/apollographql/apollo/api/MutableExecutionOptions;Z)Ljava/lang/Object;
220230
public static final fun storeExpirationDate (Lcom/apollographql/apollo/api/MutableExecutionOptions;Z)Ljava/lang/Object;
221231
public static final fun storePartialResponses (Lcom/apollographql/apollo/api/MutableExecutionOptions;Z)Ljava/lang/Void;
222232
public static final fun storeReceivedDate (Lcom/apollographql/apollo/api/MutableExecutionOptions;Z)Ljava/lang/Object;

normalized-cache/api/normalized-cache.klib.api

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ abstract interface com.apollographql.cache.normalized/CacheManager { // com.apol
113113
}
114114
}
115115

116+
abstract interface com.apollographql.cache.normalized/CacheOptions { // com.apollographql.cache.normalized/CacheOptions|null[0]
117+
abstract fun allowCachedErrors(kotlin/Boolean) // com.apollographql.cache.normalized/CacheOptions.allowCachedErrors|allowCachedErrors(kotlin.Boolean){}[0]
118+
abstract fun allowCachedPartialResults(kotlin/Boolean) // com.apollographql.cache.normalized/CacheOptions.allowCachedPartialResults|allowCachedPartialResults(kotlin.Boolean){}[0]
119+
abstract fun noCache(kotlin/Boolean) // com.apollographql.cache.normalized/CacheOptions.noCache|noCache(kotlin.Boolean){}[0]
120+
abstract fun onlyIfCached(kotlin/Boolean) // com.apollographql.cache.normalized/CacheOptions.onlyIfCached|onlyIfCached(kotlin.Boolean){}[0]
121+
abstract fun reload(kotlin/Boolean) // com.apollographql.cache.normalized/CacheOptions.reload|reload(kotlin.Boolean){}[0]
122+
}
123+
116124
sealed interface com.apollographql.cache.normalized.api/MaxAge { // com.apollographql.cache.normalized.api/MaxAge|null[0]
117125
final class Duration : com.apollographql.cache.normalized.api/MaxAge { // com.apollographql.cache.normalized.api/MaxAge.Duration|null[0]
118126
constructor <init>(kotlin.time/Duration) // com.apollographql.cache.normalized.api/MaxAge.Duration.<init>|<init>(kotlin.time.Duration){}[0]
@@ -592,8 +600,8 @@ final val com.apollographql.cache.normalized/CacheFirstInterceptor // com.apollo
592600
final fun <get-CacheFirstInterceptor>(): com.apollographql.apollo.interceptor/ApolloInterceptor // com.apollographql.cache.normalized/CacheFirstInterceptor.<get-CacheFirstInterceptor>|<get-CacheFirstInterceptor>(){}[0]
593601
final val com.apollographql.cache.normalized/CacheOnlyInterceptor // com.apollographql.cache.normalized/CacheOnlyInterceptor|{}CacheOnlyInterceptor[0]
594602
final fun <get-CacheOnlyInterceptor>(): com.apollographql.apollo.interceptor/ApolloInterceptor // com.apollographql.cache.normalized/CacheOnlyInterceptor.<get-CacheOnlyInterceptor>|<get-CacheOnlyInterceptor>(){}[0]
595-
final val com.apollographql.cache.normalized/DonkeyInterceptor // com.apollographql.cache.normalized/DonkeyInterceptor|{}DonkeyInterceptor[0]
596-
final fun <get-DonkeyInterceptor>(): com.apollographql.apollo.interceptor/ApolloInterceptor // com.apollographql.cache.normalized/DonkeyInterceptor.<get-DonkeyInterceptor>|<get-DonkeyInterceptor>(){}[0]
603+
final val com.apollographql.cache.normalized/DefaultFetchPolicyInterceptor // com.apollographql.cache.normalized/DefaultFetchPolicyInterceptor|{}DefaultFetchPolicyInterceptor[0]
604+
final fun <get-DefaultFetchPolicyInterceptor>(): com.apollographql.apollo.interceptor/ApolloInterceptor // com.apollographql.cache.normalized/DefaultFetchPolicyInterceptor.<get-DefaultFetchPolicyInterceptor>|<get-DefaultFetchPolicyInterceptor>(){}[0]
597605
final val com.apollographql.cache.normalized/NetworkFirstInterceptor // com.apollographql.cache.normalized/NetworkFirstInterceptor|{}NetworkFirstInterceptor[0]
598606
final fun <get-NetworkFirstInterceptor>(): com.apollographql.apollo.interceptor/ApolloInterceptor // com.apollographql.cache.normalized/NetworkFirstInterceptor.<get-NetworkFirstInterceptor>|<get-NetworkFirstInterceptor>(){}[0]
599607
final val com.apollographql.cache.normalized/NetworkOnlyInterceptor // com.apollographql.cache.normalized/NetworkOnlyInterceptor|{}NetworkOnlyInterceptor[0]
@@ -646,8 +654,10 @@ final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOption
646654
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/memoryCacheOnly(kotlin/Boolean): #A // com.apollographql.cache.normalized/memoryCacheOnly|memoryCacheOnly@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
647655
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/noCache(kotlin/Boolean): #A // com.apollographql.cache.normalized/noCache|noCache@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
648656
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/onlyIfCached(kotlin/Boolean): #A // com.apollographql.cache.normalized/onlyIfCached|onlyIfCached@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
657+
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/refetchCacheOptions(kotlin/Function1<com.apollographql.cache.normalized/CacheOptions, kotlin/Unit>): #A // com.apollographql.cache.normalized/refetchCacheOptions|refetchCacheOptions@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Function1<com.apollographql.cache.normalized.CacheOptions,kotlin.Unit>){0§<kotlin.Any?>}[0]
649658
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/refetchPolicy(com.apollographql.cache.normalized/FetchPolicy): #A // com.apollographql.cache.normalized/refetchPolicy|refetchPolicy@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(com.apollographql.cache.normalized.FetchPolicy){0§<kotlin.Any?>}[0]
650659
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/refetchPolicyInterceptor(com.apollographql.apollo.interceptor/ApolloInterceptor): #A // com.apollographql.cache.normalized/refetchPolicyInterceptor|refetchPolicyInterceptor@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(com.apollographql.apollo.interceptor.ApolloInterceptor){0§<kotlin.Any?>}[0]
660+
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/reload(kotlin/Boolean): #A // com.apollographql.cache.normalized/reload|reload@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
651661
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/storeExpirationDate(kotlin/Boolean): #A // com.apollographql.cache.normalized/storeExpirationDate|storeExpirationDate@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
652662
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/storePartialResponses(kotlin/Boolean): kotlin/Nothing // com.apollographql.cache.normalized/storePartialResponses|storePartialResponses@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
653663
final fun <#A: kotlin/Any?> (com.apollographql.apollo.api/MutableExecutionOptions<#A>).com.apollographql.cache.normalized/storeReceivedDate(kotlin/Boolean): #A // com.apollographql.cache.normalized/storeReceivedDate|storeReceivedDate@com.apollographql.apollo.api.MutableExecutionOptions<0:0>(kotlin.Boolean){0§<kotlin.Any?>}[0]
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.apollographql.cache.normalized
2+
3+
interface CacheOptions {
4+
fun noCache(noCache: Boolean)
5+
fun onlyIfCached(onlyIfCached: Boolean)
6+
fun reload(reload: Boolean)
7+
fun allowCachedPartialResults(allowCachedPartialResults: Boolean)
8+
fun allowCachedErrors(allowCachedErrors: Boolean)
9+
}
10+
11+
internal data class CacheOptionsImpl(
12+
var noCache: Boolean = false,
13+
var onlyIfCached: Boolean = false,
14+
var reload: Boolean = false,
15+
var allowCachedPartialResults: Boolean = false,
16+
var allowCachedErrors: Boolean = false,
17+
) : CacheOptions {
18+
override fun noCache(noCache: Boolean) {
19+
if (noCache && onlyIfCached) error("Apollo: noCache and onlyIfCached are mutually exclusive")
20+
this.noCache = noCache
21+
}
22+
23+
override fun onlyIfCached(onlyIfCached: Boolean) {
24+
if (onlyIfCached && noCache) error("Apollo: noCache and onlyIfCached are mutually exclusive")
25+
if (onlyIfCached && reload) error("Apollo: onlyIfCached and reload are mutually exclusive")
26+
this.onlyIfCached = onlyIfCached
27+
}
28+
29+
override fun reload(reload: Boolean) {
30+
if (reload && onlyIfCached) error("Apollo: onlyIfCached and reload are mutually exclusive")
31+
this.reload = reload
32+
}
33+
34+
override fun allowCachedPartialResults(allowCachedPartialResults: Boolean) {
35+
this.allowCachedPartialResults = allowCachedPartialResults
36+
}
37+
38+
override fun allowCachedErrors(allowCachedErrors: Boolean) {
39+
this.allowCachedErrors = allowCachedErrors
40+
}
41+
}

normalized-cache/src/commonMain/kotlin/com/apollographql/cache/normalized/ClientCacheExtensions.kt

Lines changed: 55 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ fun <D : Query.Data> ApolloCall<D>.watch(): Flow<ApolloResponse<D>> {
257257

258258

259259
copy().fetchPolicyInterceptor(refetchPolicyInterceptor)
260+
.fetchCacheOptions(refetchCacheOptions)
260261
.watchInternal(response?.data)
261262
.collect {
262263
if (it.exception === WatcherSentinel) {
@@ -297,18 +298,32 @@ val ApolloClient.apolloStore: ApolloStore
297298

298299
/**
299300
* Sets the initial [FetchPolicy]
300-
* This only has effects for queries. Mutations and subscriptions always use [FetchPolicy.NetworkOnly]
301+
* This only has effects for queries. Mutations and subscriptions always use the network only.
301302
*/
302-
fun <T> MutableExecutionOptions<T>.fetchPolicy(fetchPolicy: FetchPolicy) = addExecutionContext(
303-
FetchPolicyContext(interceptorFor(fetchPolicy))
304-
)
303+
@Deprecated("Use noCache(), onlyIfCached() or reload() instead")
304+
@Suppress("DEPRECATION")
305+
fun <T> MutableExecutionOptions<T>.fetchPolicy(fetchPolicy: FetchPolicy): T {
306+
return if (fetchPolicy == FetchPolicy.NetworkFirst) {
307+
// NetworkFirst is deprecated but should still work
308+
fetchPolicyInterceptor(NetworkFirstInterceptor)
309+
} else {
310+
addExecutionContext(FetchCacheOptionsContext(cacheOptionsFor(fetchPolicy)))
311+
}
312+
}
305313

306314
/**
307315
* Sets the [FetchPolicy] used when watching queries and a cache change has been published
308316
*/
309-
fun <T> MutableExecutionOptions<T>.refetchPolicy(fetchPolicy: FetchPolicy) = addExecutionContext(
310-
RefetchPolicyContext(interceptorFor(fetchPolicy))
311-
)
317+
@Deprecated("Use refetchCacheOptions() instead")
318+
@Suppress("DEPRECATION")
319+
fun <T> MutableExecutionOptions<T>.refetchPolicy(@Suppress("DEPRECATION") fetchPolicy: FetchPolicy): T {
320+
return if (fetchPolicy == FetchPolicy.NetworkFirst) {
321+
// NetworkFirst is deprecated but should still work
322+
refetchPolicyInterceptor(NetworkFirstInterceptor)
323+
} else {
324+
addExecutionContext(RefetchCacheOptionsContext(cacheOptionsFor(fetchPolicy)))
325+
}
326+
}
312327

313328
/**
314329
* Sets the initial [FetchPolicy]
@@ -325,12 +340,13 @@ fun <T> MutableExecutionOptions<T>.refetchPolicyInterceptor(interceptor: ApolloI
325340
RefetchPolicyContext(interceptor)
326341
)
327342

328-
private fun interceptorFor(fetchPolicy: FetchPolicy) = when (fetchPolicy) {
329-
FetchPolicy.CacheOnly -> CacheOnlyInterceptor
330-
FetchPolicy.NetworkOnly -> NetworkOnlyInterceptor
331-
FetchPolicy.CacheFirst -> CacheFirstInterceptor
332-
FetchPolicy.NetworkFirst -> NetworkFirstInterceptor
333-
FetchPolicy.CacheAndNetwork -> CacheAndNetworkInterceptor
343+
@Suppress("DEPRECATION")
344+
private fun cacheOptionsFor(fetchPolicy: FetchPolicy) = when (fetchPolicy) {
345+
FetchPolicy.CacheOnly -> CacheOptionsImpl(onlyIfCached = true)
346+
FetchPolicy.NetworkOnly -> CacheOptionsImpl(noCache = true)
347+
FetchPolicy.CacheFirst -> CacheOptionsImpl()
348+
FetchPolicy.NetworkFirst -> CacheOptionsImpl()
349+
FetchPolicy.CacheAndNetwork -> CacheOptionsImpl(reload = true)
334350
}
335351

336352
/**
@@ -467,13 +483,10 @@ fun <D : Mutation.Data> ApolloCall<D>.optimisticUpdates(data: D) = addExecutionC
467483
)
468484

469485
internal val <D : Operation.Data> ApolloRequest<D>.fetchPolicyInterceptor
470-
get() = executionContext[FetchPolicyContext]?.interceptor ?: CacheFirstInterceptor
471-
472-
internal val <D : Operation.Data> ApolloCall<D>.fetchPolicyInterceptor
473-
get() = executionContext[FetchPolicyContext]?.interceptor ?: CacheFirstInterceptor
486+
get() = executionContext[FetchPolicyContext]?.interceptor ?: DefaultFetchPolicyInterceptor
474487

475488
private val <T> MutableExecutionOptions<T>.refetchPolicyInterceptor
476-
get() = executionContext[RefetchPolicyContext]?.interceptor ?: CacheOnlyInterceptor
489+
get() = executionContext[RefetchPolicyContext]?.interceptor ?: DefaultFetchPolicyInterceptor
477490

478491
internal val <D : Operation.Data> ApolloRequest<D>.doNotStore
479492
get() = executionContext[DoNotStoreContext]?.value ?: false
@@ -754,57 +767,48 @@ fun <T> MutableExecutionOptions<T>.clock(clock: () -> Long): T {
754767
return this as T
755768
}
756769

757-
internal class AllowCachedPartialResultsContext(val value: Boolean) : ExecutionContext.Element {
770+
internal class FetchCacheOptionsContext(val value: CacheOptionsImpl) : ExecutionContext.Element {
758771
override val key: ExecutionContext.Key<*>
759772
get() = Key
760773

761-
companion object Key : ExecutionContext.Key<AllowCachedPartialResultsContext>
774+
companion object Key : ExecutionContext.Key<FetchCacheOptionsContext>
762775
}
763776

764-
internal val ExecutionOptions.allowCachedPartialResults: Boolean
765-
get() = executionContext[AllowCachedPartialResultsContext]?.value ?: false
766-
767-
fun <T> MutableExecutionOptions<T>.allowCachedPartialResults(allowCachedPartialResults: Boolean): T =
768-
addExecutionContext(AllowCachedPartialResultsContext(allowCachedPartialResults))
777+
internal val ExecutionOptions.fetchCacheOptions: CacheOptionsImpl
778+
get() = executionContext[FetchCacheOptionsContext]?.value ?: CacheOptionsImpl()
769779

770-
771-
internal class AllowCachedErrorsContext(val value: Boolean) : ExecutionContext.Element {
772-
override val key: ExecutionContext.Key<*>
773-
get() = Key
774-
775-
companion object Key : ExecutionContext.Key<AllowCachedErrorsContext>
780+
internal fun <T> MutableExecutionOptions<T>.fetchCacheOptions(fetchCacheOptions: CacheOptionsImpl): T {
781+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions))
782+
@Suppress("UNCHECKED_CAST")
783+
return this as T
776784
}
777785

778-
internal val ExecutionOptions.allowCachedErrors: Boolean
779-
get() = executionContext[AllowCachedErrorsContext]?.value ?: false
780-
781-
fun <T> MutableExecutionOptions<T>.allowCachedErrors(allowCachedErrors: Boolean): T =
782-
addExecutionContext(AllowCachedErrorsContext(allowCachedErrors))
783786

787+
fun <T> MutableExecutionOptions<T>.allowCachedPartialResults(allowCachedPartialResults: Boolean): T =
788+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions.also { it.allowCachedPartialResults(allowCachedPartialResults) }))
784789

785-
internal class NoCacheContext(val value: Boolean) : ExecutionContext.Element {
786-
override val key: ExecutionContext.Key<*>
787-
get() = Key
790+
fun <T> MutableExecutionOptions<T>.allowCachedErrors(allowCachedErrors: Boolean): T =
791+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions.also { it.allowCachedErrors(allowCachedErrors) }))
788792

789-
companion object Key : ExecutionContext.Key<NoCacheContext>
790-
}
793+
fun <T> MutableExecutionOptions<T>.noCache(noCache: Boolean): T =
794+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions.also { it.noCache(noCache) }))
791795

792-
internal val ExecutionOptions.noCache: Boolean
793-
get() = executionContext[NoCacheContext]?.value ?: false
796+
fun <T> MutableExecutionOptions<T>.onlyIfCached(onlyIfCached: Boolean): T =
797+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions.also { it.onlyIfCached(onlyIfCached) }))
794798

795-
fun <T> MutableExecutionOptions<T>.noCache(noCache: Boolean): T =
796-
addExecutionContext(NoCacheContext(noCache))
799+
fun <T> MutableExecutionOptions<T>.reload(reload: Boolean): T =
800+
addExecutionContext(FetchCacheOptionsContext(fetchCacheOptions.also { it.reload(reload) }))
797801

798802

799-
internal class OnlyIfCachedContext(val value: Boolean) : ExecutionContext.Element {
803+
internal class RefetchCacheOptionsContext(val value: CacheOptionsImpl) : ExecutionContext.Element {
800804
override val key: ExecutionContext.Key<*>
801805
get() = Key
802806

803-
companion object Key : ExecutionContext.Key<OnlyIfCachedContext>
807+
companion object Key : ExecutionContext.Key<RefetchCacheOptionsContext>
804808
}
805809

806-
internal val ExecutionOptions.onlyIfCached: Boolean
807-
get() = executionContext[OnlyIfCachedContext]?.value ?: false
810+
internal val ExecutionOptions.refetchCacheOptions: CacheOptionsImpl
811+
get() = executionContext[RefetchCacheOptionsContext]?.value ?: CacheOptionsImpl(onlyIfCached = true)
808812

809-
fun <T> MutableExecutionOptions<T>.onlyIfCached(onlyIfCached: Boolean): T =
810-
addExecutionContext(OnlyIfCachedContext(onlyIfCached))
813+
fun <T> MutableExecutionOptions<T>.refetchCacheOptions(refetchCacheOptions: CacheOptions.() -> Unit): T =
814+
addExecutionContext(RefetchCacheOptionsContext(this.refetchCacheOptions.also { refetchCacheOptions(it) }))

0 commit comments

Comments
 (0)