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

FetchPolicy CacheAndNetwork does not work properly #1036

Closed Veeksi closed 2 years ago

Veeksi commented 2 years ago

Describe the issue FetchPolicy CacheAndNetwork uses only network even though the query / data does not change

To reproduce Here is sample application which shows the issue. https://github.com/Veeksi/graphgl_issue

  1. Firstly, you run the application with FetchPolicy CacheAndNetwork which uses a network connection for the first fetch
  2. Then, you receive data like normally
  3. After that you reload the application or refresh it, and I except that it should use cache this time because the query is exactly the same but instead it uses still network
  4. However, when I change the FetchPolicy to CacheOnly it uses cache properly and returns right result

Expected behavior FetchPolicy CacheAndNetwork should return first from network and after that from cache if the data / query does not change

Device I have tested the application with both physical Android device and with emulator

Additional context