Added the ability to provide a fetchPolicy to ObservableQuery.fetchResults
Use case
I'll usually hook up an observable with the fetchResults parameter set to false and then periodically call fetchResults on it.
ObservableQuery observableQuery = client.watchQuery(
WatchQueryOptions(
fetchPolicy: fetchPolicy,
// Tells the watch not to fetch right away. Trigger with `fetchResults`
fetchResults: false,
variables: options.variables,
document: options.document,
),
);
observableQuery.fetchResults();
But on subsequent calls to fetchResults, I might want to tell it to fetch from network only, cache only, etc. A concrete example being that I'd like to initialize this observable to start with a fetchPolicy of onlyCache. Then when the user pulls to refresh, I'd like to trigger fetchResults(networkOnly).
Currently, I'd need to initialize a new observable or use a new async / await call, even though my listener would be the same.
I also might be misusing the library, so please let me know if this makes sense!
Fixes / Enhancements
Added the ability to provide a fetchPolicy to ObservableQuery.fetchResults
Use case
I'll usually hook up an observable with the
fetchResults
parameter set to false and then periodically callfetchResults
on it.But on subsequent calls to
fetchResults
, I might want to tell it to fetch from network only, cache only, etc. A concrete example being that I'd like to initialize this observable to start with a fetchPolicy ofonlyCache
. Then when the user pulls to refresh, I'd like to triggerfetchResults(networkOnly)
.Currently, I'd need to initialize a new observable or use a new async / await call, even though my listener would be the same.
I also might be misusing the library, so please let me know if this makes sense!