Marco Pierucci
11/14/2023, 10:18 PMApolloClient.Builder()
...
.normalizedCache(SqlNormalizedCacheFactory(APOLLO_CACHE_DB))
.fetchPolicy(FetchPolicy.NetworkOnly)
...
And :
suspend fun fetchEngineerTimeline(
date: LocalDate,
): EngineerTimeline = apolloClient.query(
GetEngineerTimelineQuery(date = Optional.Present(date))
).fetchPolicy(FetchPolicy.NetworkOnly)
But on the DB inspector I can isee entries for other queries where I have not added any cache policymbonnin
11/14/2023, 10:38 PMcacheHeader()
function that should take a NO_CACHE
value or soMarco Pierucci
11/14/2023, 10:51 PMobject ApolloCacheHeaders {
/**
* Records from this request should not be stored in the [NormalizedCache].
*/
const val DO_NOT_STORE = "do-not-store"
Where can I see some doc on how to use this ones?
( For when you are back ofc)Marco Pierucci
11/14/2023, 11:00 PM/**
* @param doNotStore Whether to store the response in cache.
*
* Default: false
*/
fun <T> MutableExecutionOptions<T>.doNotStore(doNotStore: Boolean) = addExecutionContext(
DoNotStoreContext(doNotStore)
)
Marco Pierucci
11/14/2023, 11:00 PMmbonnin
11/15/2023, 9:17 AMdoNotStore()
, this is the way 👍
About making it a default, ApolloClient.Builder
implements MutableExecutionOptions
so you can do this:
ApolloClient.Builder()
.serverUrl(..)
// more stuff
.doNotStore(true)
.build()
Not that all the requests have a fetch policy though. Even if you don't set it explicitely, it will default to CacheFirst
once you configure the cache.
If you want to change that behaviour, you can define your own extension function:
fun <D: Operation.Data> ApolloCall<D>.myFetchPolicy(fetchPolicy: FetchPolicy): ApolloCall<D> = doNotStore(false).fetchPolicy(fetchPolicy)
Marco Pierucci
11/15/2023, 9:53 AMMarco Pierucci
11/15/2023, 10:23 AMError:(2, 14) 'FieldUserAppointmentType' tried to use an undeclared directive 'typePolicy'
I get this once I added the declarative id in the extras.grapqhls file.
Cant find much online, could it be just a plugin issue?Marco Pierucci
11/15/2023, 10:24 AMStylianos Gakis
11/15/2023, 10:25 AMMarco Pierucci
11/15/2023, 10:26 AMmbonnin
11/15/2023, 10:27 AMmbonnin
11/15/2023, 10:27 AMMarco Pierucci
11/15/2023, 10:32 AMbod
11/15/2023, 10:36 AMMarco Pierucci
11/15/2023, 10:40 AM