zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.25k stars 620 forks source link

fix: Read from cache first on cacheAndNetwork #1038

Closed budde377 closed 2 years ago

budde377 commented 2 years ago

When fetch policy is cacheAndNetwork, we now return cache and then fetch from the network, if the cached result is available). If not we fetch from the network.

The current implementation always awaits the network response if available. But when the fetch policy is cacheAndNetwork we first want to return the cached result (if available) and then continue to fetch over the network in background. This PR fixes this.

codecov[bot] commented 2 years ago

Codecov Report

Merging #1038 (fb09fe8) into beta (05ca62a) will increase coverage by 0.27%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             beta    #1038      +/-   ##
==========================================
+ Coverage   51.25%   51.53%   +0.27%     
==========================================
  Files          36       36              
  Lines        1389     1397       +8     
==========================================
+ Hits          712      720       +8     
  Misses        677      677              
Impacted Files Coverage Δ
packages/graphql/lib/src/core/query_manager.dart 68.45% <100.00%> (+1.57%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 405e8bd...fb09fe8. Read the comment docs.

vytautas-pranskunas- commented 2 years ago

Thanks guys!

kuba-asanov commented 2 years ago

Good job!