startPolling method
Poll the server periodically for results.
Will be called by fetchResults automatically if options.pollInterval
is set
Implementation
void startPolling(Duration? pollInterval) {
if (options.fetchPolicy == FetchPolicy.cacheFirst ||
options.fetchPolicy == FetchPolicy.cacheOnly) {
throw Exception(
'Queries that specify the cacheFirst and cacheOnly fetch policies cannot also be polling queries.',
);
}
if (isCurrentlyPolling) {
scheduler!.stopPollingQuery(queryId);
}
options = options.copyWithPollInterval(pollInterval);
lifecycle = QueryLifecycle.polling;
scheduler!.startPollingQuery(options, queryId);
}