File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
packages/graphql/lib/src/core Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -182,12 +182,18 @@ class ObservableQuery<TParsed> {
182182 }
183183 }
184184
185- /// Fetch results based on [options.fetchPolicy]
185+ /// Fetch results based on [options.fetchPolicy] by default.
186+ ///
187+ /// Optionally provide a [fetchPolicy] which will override the
188+ /// default [options.fetchPolicy] , just for this request.
186189 ///
187190 /// Will [startPolling] if [options.pollInterval] is set
188- MultiSourceResult <TParsed > fetchResults () {
191+ MultiSourceResult <TParsed > fetchResults ({FetchPolicy ? fetchPolicy}) {
192+ final fetchOptions = fetchPolicy == null
193+ ? options
194+ : options.copyWithFetchPolicy (fetchPolicy);
189195 final MultiSourceResult <TParsed > allResults =
190- queryManager.fetchQueryAsMultiSourceResult (queryId, options );
196+ queryManager.fetchQueryAsMultiSourceResult (queryId, fetchOptions );
191197 latestResult ?? = allResults.eagerResult;
192198
193199 if (allResults.networkResult == null ) {
@@ -201,8 +207,8 @@ class ObservableQuery<TParsed> {
201207 : QueryLifecycle .pending;
202208 }
203209
204- if (options .pollInterval != null && options .pollInterval! > Duration .zero) {
205- startPolling (options .pollInterval);
210+ if (fetchOptions .pollInterval != null && fetchOptions .pollInterval! > Duration .zero) {
211+ startPolling (fetchOptions .pollInterval);
206212 }
207213
208214 return allResults;
You can’t perform that action at this time.
0 commit comments